use 5.010; sub f { state $i = 0; ++$i; } say f; say f; say f; __END__ 1 2 3