use feature qw( :5.10 ); print counter(), "\n"; sub counter { state $count = 0; return $count++; } print counter(), "\n"; __END__ 0 1