use Tie::Static qw(static); sub persist { static \ (my $var); ++$var; }