explain code section please...
- From: "onlineviewer" <lancerset@xxxxxxxxx>
- Date: 28 Aug 2006 13:41:48 -0700
Hello All,
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' then the find method is
called with the $callback reference and the bin directory. Then the
subroutine executes on each of the contents of the bin directory. Is
that right so far ?? Thanks...
use File::Find;
sub create_find_callback_that_sums_the_size {
my $total_size = 0;
return sub {
if (@_) {
return $total_size;
} else {
$total_size += -s if -f;
}
};
}
my $callback = create_find_callback_that_sums_the_size( );
find($callback, "bin");
my $total_size = $callback->("dummy");
print "total size of bin is $total_size\n";
.
- Follow-Ups:
- Re: explain code section please...
- From: John W. Krahn
- Re: explain code section please...
- From: Mumia W.
- Re: explain code section please...
- Prev by Date: ANNOUNCE: Text-Bidi-0.01
- Next by Date: Re: explain code section please...
- Previous by thread: ANNOUNCE: Text-Bidi-0.01
- Next by thread: Re: explain code section please...
- Index(es):