John W. Krahn wrote:
Brian wrote:
Hello
Hello,
<snip>
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';}
The first } is the end of the while block and the second } is the end of
the anonymous subroutine and ", '/test';" is the second argument to
find() and not part of the anonymous subroutine. Another way to write
that is:
sub wanted {
return unless -f;
open my $FH, '<', $_ or die "Cannot open '$_' $!";
while ( <$FH> ) {
/\Q$string/ && print $REPORT "$File::Find::name\n" and return;
}
}
find \&wanted, '/test';
John
Thanks John, things are starting to get clearer :-)
regards
Brian
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/