state declares a lexically scoped variable, just like my does.
However, those variables will never be reinitialized, contrary to
lexical variables that are reinitialized each time their enclosing block
state variables are enabled only when the usefeature"state"
is in effect. See feature.
perldoc.perl.org - Official documentation for the Perl programming language