in reply to Pass an "extra' variable to Find::File subroutine
This is the general way to handle such problems in Perl. You can abstact that away with closures:my $source = “/mnt/usbdisk”; sub Recursive { my $msg = $source; ... {
sub myfind { my ($code, @args) = @_; find(sub { $code->(@args)}) }
Now you can call
myfind \&Recursive, $source;
And have the argument $source passed through to sub Recursive. But most likely you can solve your problem with outer lexical variables in the first place.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Pass an "extra' variable to Find::File subroutine
by almut (Canon) on Jun 22, 2010 at 13:56 UTC | |
by moritz (Cardinal) on Jun 22, 2010 at 14:23 UTC | |
by timtowtdi (Sexton) on Jun 23, 2010 at 05:11 UTC |