MJD wrote: > That is talking about something else that is irrelevant in this case. > That paragraph refers to this situation; > > { my $obj = Class->new; > ... > } > > B; > > The question here is whether Class::DESTROY is called immediately at > the end of the block, before B is executed. The paragraph you quote > is warning us that that might not be the case. Well I read that as a general observation that you cant count on DESTROY being called at any particular time, which to me implys order. > However, the problem I am reporting is a different situation. Here, a > piece of data is destroyed prematurely, while there is still a > reference to it. That is not the same thing at all; Perl *does* > guarantee that it will not destroy an object that is reachable from an > executing program. Only in normal destruction. It _cant_ make the guarantee that you say it does or circular structures would never be broken during global destruction: my $x=bless {},'Foo'; my $y=bless {},'Foo'; $x->{y}=$y; $y->{x}=$x; my $z; $z=bless \$z,"Foo"; sub Foo::Destroy { print "Destroying: @_\n" } > > Im wondering why Perl doesn't have a counter whose value is incremented and > > assigned to each blessed object when they are blessed. > > It maintains a count of the number of references to each object; this > count is intended to prevent exactly the behavior I am reporting. Not in global destruction though. Refcounting can't help there at all. That's why I was suggesting the counter approach. At least then you could know that the objects would be destroyed in a defined order. yvesThread Previous | Thread Next