Telemachus wrote:
On Mon Oct 27 2008 @ 5:05, Brian wrote:
An example of something confusing me is in the sample below
find sub {
return unless -f;
open my $FH, '<', $_ or die "Cannot open '$_' $!";
while ( <$FH> ) {
/\Q$string/ && print $REPORT "$File::Find::name\n" and
return;
}}, '/test';
Why isn't the last line
}, '/test';}
Does this make it any better?
find sub {
return unless -f;
open my $FH, '<', $_ or die "Cannot open '$_' $!";
while ( <$FH> ) {
/\Q$string/ && print $REPORT "$File::Find::name\n" and return;
} # close the while loop
}, '/test'; # close the sub and run the subroutine on the directory '/test'
The first brace closes the while loop. The second closes the subroutine.
The subroutine itself is an anonymous one with the directory to process
placed immediately following.
In a nutshell, instead of this:
find( \&subroutine, '/test' );
you can write this:
find sub { stuff; }, '/test';
Hope this helps, T
Thanks, I was missing the point, and can now see that it was
{do this}, here;
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/