Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: About "state" variables in Perl 5.10

by TimToady (Parson)
on Dec 28, 2007 at 17:49 UTC ( #659362=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
        {
            my $x = 42;
            my $s = sub { $x++ };
            say &$s();
        }
    
  2. or download this
        my $s = sub { state $x = 42; $x++ };
        say &$s();
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://659362]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2021-05-15 03:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Perl 7 will be out ...





    Results (150 votes). Check out past polls.

    Notices?