http://qs1969.pair.com?node_id=103642


in reply to (tye)Re: Tie & Destroy, OOP
in thread Tie & Destroy, OOP

Not true. On 5.005_03 try this:
my $foo = be({name => "foo"}); my $bar = be({name => "bar", data => $foo}); my $baz = be({name => "baz", data => $bar}); sub gotcha { $bar->{"bar can't go"} = "until this function is cleaned up"; } sub be { return bless shift; } sub DESTROY { my $self = shift; print "$self->{name} died\n"; } __END__ on 5.005_03 for me prints: baz died foo died bar died
Note that $foo is going away before $bar. Remove the function holding $bar to global destruction and everything will clean up properly. Make them all global and you will again run into trouble.