in reply to Re: Rules of Lexical Scoping
in thread Rules of Lexical Scoping

I think that's quite inaccurate. Lexical variables are cleared on block exit and re-used unless there are still references to them.
That is an optimization, and the documentation specifically warns against relying on it as your example does.

The "discarded" doesn't mean literally freeing the pad SV. Here:

$ perl5.10.0 -we'{ my $x; sub foo { eval q!print $x! } foo }' Use of uninitialized value $x in print at (eval 1) line 1. $ perl5.10.0 -we'{ my $x; sub foo { eval q!print $x! } } foo' Variable "$x" is not available at (eval 1) line 2. Use of uninitialized value $x in print at (eval 1) line 1.
$x is logically discarded and hence "not available" after the scope is exited, even though the SV may still stay in the pad.