in reply to Pass an "extra' variable to Find::File subroutine
\&Recursive is a callback function (or more precisely, a reference to it) that is being called by File::Find as it walks through the tree. Why do you want to pass it a parameter?
Maybe you want a closure(?) Something like this:
use File::Find; my $source = "/mnt/usbdisk"; sub make_wanted { my $arg = shift; return sub { my $diskpathfile = $File::Find::name; print "$arg: $diskpathfile\n"; } } find (make_wanted("hello"), $source);
Here, make_wanted() returns a parameterized function (closure) to be used as the callback routine, i.e. the function instance retains its parameter "hello" as $arg.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Pass an "extra' variable to Find::File subroutine
by moritz (Cardinal) on Jun 22, 2010 at 13:17 UTC | |
by ikegami (Patriarch) on Jun 22, 2010 at 15:42 UTC | |
by moritz (Cardinal) on Jun 22, 2010 at 16:03 UTC | |
by ikegami (Patriarch) on Jun 22, 2010 at 17:16 UTC |