Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

Re: Re^3: Can't localize lexical variable $var at...

by Courage (Parson)
on Jun 09, 2002 at 20:57 UTC ( #172968=note: print w/replies, xml ) Need Help??

in reply to Re^3: Can't localize lexical variable $var at...
in thread Can't localize lexical variable $var at...

You did not understood what I meant.
{ my $var=2; sub inc {return $var++} sub dec {return $var--} } print inc; print dec;
Those subs see that $var which is not seen outside that block, and perl doc says this is a trick to have private static variables.

Courage, the Cowardly Dog.

Replies are listed 'Best First'.
Re^5: Can't localize lexical variable $var at...
by Aristotle (Chancellor) on Jun 09, 2002 at 21:06 UTC
    Now you are talking about closures. I do not see how that is relevant to localized globals?

    Makeshifts last the longest.

      Because I am sad I can not localize lexicals (declared via 'my'), and this item was at the very beginning of my question.

      Thanks to all people (including you) that helped me understanding this and related things.

      Courage, the Cowardly Dog.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://172968]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (6)
As of 2018-06-19 03:44 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (111 votes). Check out past polls.