why DESTROY is called after the outer { } ? after the if() block $h is no longer reachable, so why still holds a reference to the blessed instance?package H; sub DESTROY { print "DESTROY\n"; } sub new { my $class = shift; bless {}, $class; } { if(my $h = H->new()) { print "IN\n"; } print "\$h out of scope\n"; } print "why now?\n"; _____ IN $h out of scope DESTROY why now?
Oha
edit: This is perl, v5.10.0 built for i486-linux-gnu-thread-multi
In reply to if(my) scope by oha
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |