in reply to Re^4: Debugger and lexicals
in thread Debugger and lexicals

Stricly speaking $a is not optimised away; it just has a short life span, as as I pointed out earlier.
$ cat /tmp/Foo.pm package Foo; sub DESTROY { print "DESTROY\n" } my $a = bless {}; print "executing Foo\n"; $ perl -I/tmp -e'use Foo; BEGIN { print "BEGIN\n" }' executing Foo DESTROY BEGIN

Dave.

Replies are listed 'Best First'.
Re^6: Debugger and lexicals
by Anonymous Monk on Aug 07, 2011 at 13:37 UTC

    Stricly speaking $a is not optimised away; it just has a short life span, as as I pointed out earlier.

    Yeah, because it isn't attached to any scratchpad

      Its attached to the scratchpad of the CV that is created by compiling Foo. After Foo is executed, that CV and its scratchpad are freed, and $a gets freed at that point since there aren't any other references to it.

      Dave.