|
Posted by John W. Krahn on August 28, 2006, 9:00 pm
Please log in for more thread options
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
|