http://qs321.pair.com?node_id=757929

oha has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I got a strange issue I would like to share, in the following code:
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?
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?

Oha

edit: This is perl, v5.10.0 built for i486-linux-gnu-thread-multi