Just keep in mind that the variable declaration only happens if you call the sub after it's been declared, so you either need to "use" the function or call it from below, like in my example:
use strict;
use warnings;
{
my $persistent = 0;
sub increment {
print ++$persistent;
}}
increment();
increment();
increment();