You'll need to use globals or closures:
or# From almut sub make_wanted { my $arg = shift; return sub { my $diskpathfile = $File::Find::name; print "$arg: $diskpathfile\n"; } } my $arg = "hello"; find(make_wanted($arg), $source);
orsub wanted { my ($arg) = @_; my $diskpathfile = $File::Find::name; print "$arg: $diskpathfile\n"; } my $arg = "hello"; find(sub { wanted($arg) }, $source);
ormy $arg = "hello"; find(sub { my $diskpathfile = $File::Find::name; print "$arg: $diskpathfile\n"; }, $source);
my $arg = "hello"; sub wanted { my $diskpathfile = $File::Find::name; print "$arg: $diskpathfile\n"; } find(\&wanted, $source);
In reply to Re: Pass an "extra' variable to Find::File subroutine
by ikegami
in thread Pass an "extra' variable to Find::File subroutine
by timtowtdi
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |