http://www.perlmonks.org?node_id=96053


in reply to Re: A Real Closure
in thread Unusual Closure Behaviour

Err, the warning is due to defining a function (that ends up acting as a closure, due to its use of lexicals defined in an upper scope) inside a function. But if you write:
{ my $x; sub count { ++$x } }
Then $x is private to &count, and because &count refers to a lexical that "should" have "gone away", it is a closure. At least, that is what I have understood from Randal.

japhy -- Perl and Regex Hacker