$ perl -wE 'sub f {state (my $x); say ++$x} f; f;' 1 1 $ perl -wE 'sub f {my (state $x); say ++$x} f; f;' 1 2 $ perl -wE 'sub f {state my $x; say ++$x} f; f;' No such class my at -e line 1, near "{state my" Execution of -e aborted due to compilation errors.