use strict; use warnings; use feature qw( say state ); my $x = 42; for (1 .. 2) { for (1 .. 3) { state $x; ++$x; say "\$x = $x"; } say "state \$x is out of scope here"; say "\$x = $x"; } #### 16:48 >perl 1626_SoPW.pl $x = 1 $x = 2 $x = 3 state $x is out of scope here $x = 42 $x = 4 $x = 5 $x = 6 state $x is out of scope here $x = 42 16:48 >