in reply to Re^6: memory leak when using tail recursion?
in thread memory leak when using tail recursion?

I confused "scope" with "stack frame". While if creates a lexical scope, no stack frame is created.

Because if creates a lexical scope, the following dies:

>perl -e "use strict; if (my $x = foo()) { } print $x; Global symbol "$x" requires explicit package name at -e line 1. Execution of -e aborted due to compilation errors.

If if created a stack frame, the following would print abcde instead of abced:

sub P1::DESTROY { print 'd'; } sub P2::DESTROY { print 'c'; } { print('a'); if (my $x = bless({}, 'P1')) { my $y = bless({}, 'P2'); print('b'); } print('e'); } print("\n");

Anyway, I didn't find an answer to your question.