#state.pl
use v5.010;
sub function{
state $var= 0;
$var++;
print "Now \$var state is :",$var,"\n";
}
&function
&function
&function
#輸出結果:
hello $n now is :1
hello $n now is :2
hello $n now is :3
_______________________________________
#state.pl
use v5.010;
sub function{
my $var= 0;
$var++;
print "Now \$var state is :",$var,"\n";
}
&function
&function
&function
#輸出結果:
hello $n now is :1
hello $n now is :1
hello $n now is :1
- state EXPR
沒有留言:
張貼留言