Just another Perl shrine | |
PerlMonks |
Re: help with scoping (code), part 1by Fastolfe (Vicar) |
on Nov 04, 2001 at 03:20 UTC ( [id://123109]=note: print w/replies, xml ) | Need Help?? |
I'm not sure I parsed your question correctly. How do you tell if sub_two is a "help" sub? What is a "help" sub? What do you need to call all of the subs in @children? This anonymous subroutine in sub_two? And when you say "all of the subs", you mean sub_one and sub_two, yes? So basically, the problem is that you need this subroutine sub_two to be able to access @children, yes? In your other question, a poster discussed the use of a simple block to wrap around your functions: So long as the subroutine in question is declared within the same lexical scope as the variable, you're OK. This may mean you need to move 'my @children = (...)' higher up in your file, or use our instead of my as you suggest. After that, you can execute these subroutines in any fashion, and they'll still end up seeing the same variables in the same lexical scope.
In Section
Seekers of Perl Wisdom
|
|