in reply to Re: Making a variable in a sub retain its value between calls
in thread Making a variable in a sub retain its value between calls

Unforuately, a reference to the object must be passed to the function, and the OP explicitely requested that the solution didn't do this. I do like passing a state object as you suggest, though. There's much less hidden mojo that way.

Sorry for this banal reply. The original version of it was completely wrong.

  • Comment on Re^2: Making a variable in a sub retain its value between calls

Replies are listed 'Best First'.
Re^3: Making a variable in a sub retain its value between calls
by mattr (Curate) on Apr 24, 2005 at 14:27 UTC
    Ah, my bad.
    I was a little confused what he was getting at. Also was thinking "well you could use a global but that would not be so elegant.." etc. I guess there is a good time to use closures like above.
    Thanks!
    Matt