mdunnbass has asked for the wisdom of the Perl Monks concerning the following question:
If I am just missing an FAQ, please forgive me, but I didn't see this in either the Q&A or via Supersearch.
I have many many subs in my program, many called sequentially, or from within other subs. Some of these down-the-line subs require inputs from the output of a sub 5 or 6 places back up the line. i.e.
What I've been doing so far has been passing the variable through each and every intervening sub. I had originally made them global rather than scoped to each individual sub, but many people were suggesting that was a big drain on memory, esp since some of these are huge arrays, etc.sub First { # do something.... return $info_required_not_until_sub_seven; } sub Seventh { my $input_from_first = shift; my $input_from_fourth = shift; my $input_from_sixth = shift; #etc... }
My question is, is there a way to hold on to a locally scoped variable, to pass it on later, or even something along the lines of :
?from sub FIRST get $input_required_not_until_seventh
Thanks,
Matt
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Getting variables from mulitple subs at once?
by ikegami (Patriarch) on Feb 19, 2007 at 17:36 UTC | |
by mdunnbass (Monk) on Feb 20, 2007 at 14:24 UTC | |
|
Re: Getting variables from mulitple subs at once?
by philcrow (Priest) on Feb 19, 2007 at 17:30 UTC | |
by mdunnbass (Monk) on Feb 20, 2007 at 14:17 UTC | |
|
Re: Getting variables from mulitple subs at once?
by ferreira (Chaplain) on Feb 19, 2007 at 17:33 UTC | |
by mdunnbass (Monk) on Feb 20, 2007 at 14:15 UTC |