find( sub { my ($spls) = @_; ... }, $seek_path );
I think File::Find (which I figure is being used by the OP) doesn't actually pass the "wanted" callback function any arguments, so assigning my ($spls) = @_; wouldn't achieve the desired effect. It should work just fine without the assigment, however... A stripped-down runnable example:
#!/usr/bin/perl use File::Find; my $seek_path = "/usr/bin"; my @spt1 = qw(perl py); foreach my $spls (@spt1) { find( sub { print "^$spls : $_\n" if /^$spls/; }, $seek_path ); } __END__ $ ./728317.pl ^perl : perl ^perl : perlbug ^perl : perlcc ^perl : perldoc ^perl : perlivp ^perl : perl5.8.8 ^py : pydoc ^py : python ^py : python2.4
In reply to Re^2: How to pass a variable to a subroutine
by almut
in thread How to pass a variable to a subroutine
by learningperl01
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |