in reply to How to pass a variable to a subroutine
Don't put named subs inside other named subs. Didn't you notice the "won't stay shared" warning? Anonymous subs, on the hand, are fine.
sub wanted { my ($spls) = @_; ... you can use $spls here ... } sub search { ... find(sub { wanted($spls) }, $seek_path); ... }
or
sub search { ... find( sub { ... you can use $spls here ... }, $seek_path ); ... }
Update: Fixed copy and paste error almust brought up in a reply.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: How to pass a variable to a subroutine
by almut (Canon) on Dec 05, 2008 at 18:19 UTC | |
by ikegami (Patriarch) on Dec 06, 2008 at 05:56 UTC | |
by learningperl01 (Beadle) on Dec 06, 2008 at 22:12 UTC | |
by ikegami (Patriarch) on Dec 06, 2008 at 22:43 UTC | |
by learningperl01 (Beadle) on Dec 06, 2008 at 23:13 UTC | |
|