Persistent Private Variables 

use feature qw( state );

sub next_key {
    state $x = 1;
    return $x++;
}

next_key();    # 1
next_key();    # 2