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

There's no special modifier in Perl, so doing a closure as you are doing is the best way. $memory can only be accessed by test(), so it's identical to static vars in C and (I presume) in VB.
  • Comment on Re: Making a variable in a sub retain its value between calls

Replies are listed 'Best First'.
Re^2: Making a variable in a sub retain its value between calls
by phaylon (Curate) on Apr 18, 2005 at 20:45 UTC
    Yep. And I would see the possibilities (e.g. sharing static var's for a subset of functions) as a win.

    Ordinary morality is for ordinary people. -- Aleister Crowley