Is the compiler "smart enough" to know that I exited the loop and therefore the memory allocated to $j can now be reclaimed?
Perl doesn't reclaim lexicals, it just clears them. And yes, $j gets cleared.
sub DESTROY { print("DESTROYED\n"); } for ( my $i = 0; $i < 10; $i++ ) { my $j = bless({}); if ( $i == 0 ) { goto newlocation; } } newlocation: print( "jumped out" );
DESTROYED jumped out
In reply to Re^2: GOTO or not GOTO
by ikegami
in thread GOTO or not GOTO
by jflevi
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |