f the reference count of $h goes to zero, it is automatically freed by perl,
But why does it go to zero where it does.
package H;
sub DESTROY { print "DESTROY\n"; }
sub new { my $class = shift; bless {}, $class; }
{
print \$h, "\n";
if(my $h = H->new()) {
print \$h, "\n";
}
print \$h, "\n"; # <- This references the package var
# and would cause a strict error.
# Object is no longer accessible.
print "why now?\n";
} # <- The object is only destroyed here.
SCALAR(0x1829aac)
REF(0x1829abc)
SCALAR(0x1829aac)
why now?
DESTROY
|