in reply to How can I call other objects from my object during DESTROY

Depending on what you're doing, you might either make sure that your variables are gone before global destruction (by, for instance, making them all in an inner lexical scope), or maybe to just ignore doing certain cleanup during global destruction. You can tell if you're in global destruction using this trick:

package MyStuff; my $ending = 0; sub END { $ending = 1 } sub DESTROY { return if $ending; # more cleanup here }

Of course, it depends on what kind of cleanup you need to do; writing to files, etc. would not be something you'd want to skip, while you could probably skip closing them.

Replies are listed 'Best First'.
(tye)Re2: How can I call other objects from my object during DESTROY
by tye (Sage) on Jul 11, 2001 at 03:08 UTC

    Last time I tested, just using lexical variables (my), even if they were at "file scope" was enough to prevent this problem.

            - tye (but my friends call me "Tye")