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.

  • Comment on Re: Getting variables from mulitple subs at once?

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
    Thanks for the thoughts. I'll try to read more about closures, as I am not sure I understand. I'll give it a look though. As for reforumlating the algorithm, I have reworked it numerous times, and believe me or not, this is by far the most logical and sane version.

    Matt