Re: explain code section please...



thx,

John W. Krahn wrote:
onlineviewer wrote:

John W. Krahn wrote:

onlineviewer wrote:
Can someone please explain this code section to me. This is from the
O'reilly book. learning objects,references. I see the end result, but i
am not sure how and in what order it runs. I see that the $callback
variable is a reference to the subroutine,
'create_find_callback_that_sums_the_size'

Wrong. $callback is a reference to an anonymous sub that is CREATED by
'create_find_callback_that_sums_the_size'.

perldoc -q closure

then the find method is
called with the $callback reference and the bin directory.

Correct.

Then the
subroutine executes on each of the contents of the bin directory. Is
that right so far ?? Thanks...

File::Find::find traverses the directory tree starting at 'bin' and for each
entry it calls the subroutine supplied by you and puts the name of that entry
in the $_ variable.

Thanks for the replies, it is very helpful. One more question, is the
subroutine called for as many elements that there are in the bin
directory,

Yes.

or is the subroutine being invoked only once and the
contents of bin are being copied into the subroutine to be worked on

No.


John
--
use Perl;
program
fulfillment

.



Relevant Pages

  • Re: explain code section please...
    ... John W. Krahn wrote: ... subroutine executes on each of the contents of the bin directory. ...
    (comp.lang.perl.modules)
  • Re: how can a module tell if its caller is using some other module
    ... John W. Krahn wrote: ... a defined subroutine; you can check to see if ... a "carp" method is available (if you're writing ...
    (comp.lang.perl.moderated)
  • Re: explain code section please...
    ... onlineviewer wrote: ... $callback is a reference to an anonymous sub that is CREATED by ... subroutine executes on each of the contents of the bin directory. ...
    (comp.lang.perl.modules)
  • Re: What happened? Non of VB code works
    ... Find a simple subroutine with only a few lines in your application. ... Providing Customers A Resource For Help With Access, Excel And Word ... Applications ...
    (comp.databases.ms-access)
  • Re: Ballerina Terminatrix!!
    ... >> I do have a feeling that Cameron is running some subroutine that keeps ... >> her essentially on the side of the machines though ... but she told Sarah and John from the start that her loyalty ...
    (uk.media.tv.misc)