in reply to Getting variables from mulitple subs at once?
My question is, is there a way to hold on to a locally scoped variable, to pass it on later
I think that a solution to the question you formulated will, in the long time, cause you more problems than it solves. Global variables are bad (most of the time). Abuse of local variables hurts. Strange dependencies to nesting depth of sub invocations will probably be naughty.
I think two sane approaches could be:
The solution with closures involves defining subs inside subs and accessing, when you need, variables of an upper lexical scope. The other involves decreasing the number of variables by stuffing the values into fields/attributes of objects/structures that make sense to the problem at hand and accessing them wisely.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Getting variables from mulitple subs at once?
by mdunnbass (Monk) on Feb 20, 2007 at 14:15 UTC |