Var::State - Static variable in perl 5.8


Var-State documentation  | view source Contained in the Var-State distribution.

Index


NAME

Top

Var::State - Static variable in perl 5.8

VERSION

Top

0.05

SYNOPSIS

Top

 use Var::State;

 sub foo {
     static my $i = 0;
     return $i++;
 }

 print foo() for(0..10); # will print 0 to 10

FUNCTIONS

Top

static(var)

Does almost the same as state in 5.10, but it requires the variable to be declared with "my". See SYNOPSIS for example.

This function does support list context, something state in 5.10 does not support.

state

See LIMITATIONS.

import

Will import static() into the current namespace.

LIMITATIONS

Top

Need to add state as a keyword, so you don't have to declare the variable with my() first. This exact problem breakes compatibility with 5.10's state, and therefore t/11-state-5.10.t is not included in the test-suite.

BUGS

Top

Please report any bugs or feature requests to bug-var-state at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Var-State. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

AUTHOR

Top

Jan Henning Thorsen, <pm at flodhest.net>

COPYRIGHT & LICENSE

Top


Var-State documentation  | view source Contained in the Var-State distribution.