Re: explain code section please...



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

  • Nonsense dialog box of "Sub or Function not defined"
    ... then based on the checked boxes on the ... I will be adding at least may be 15-18 more subroutine. ... .InsertBefore PLName ... Word 2007 Developer Reference> Visual Basic for Applications Language ...
    (microsoft.public.word.vba.general)
  • Re: Assumed-shape arrays and dummy procedures
    ... "If the interface of the dummy argument is implicit and either the ... a reference of the actual argument procedure. ... lies in subroutine C, and here the program really is nonconforming, ...
    (comp.lang.fortran)
  • Re: Fortran 2003: Procedure pointers
    ... >> to the function in the same scoping unit. ... implicit interface and is referenced as a subroutine, ... leaves open the possibility that if the pointer isn't referenced ... which you can't directly reference the darned thing. ...
    (comp.lang.fortran)
  • Re: Are sub-routines parameters called by reference or called by value?
    ... OUTSIDE the subroutine or not? ... it is passed "by reference", ... I would be very glad with a solution from reliable source. ... I also referred to "Windows 2000 Windows Script Host" by Tim Hill before my ...
    (microsoft.public.scripting.vbscript)
  • Re: Passing variables from one subroutine to another....
    ... reference to a subroutine. ... option is executed when a response to a SNMP message is received, ... defined as an array reference, all elements in the array are passed to ...
    (perl.beginners)