in reply to Re: Destructor Order
in thread Destructor Order

Yes, the problem is happening during global destruction.

I tried an END block, and it works, with some caveats. It seems END blocks don't fire if the script exits from an uncaught signal, which is how the script is exiting, at least while I'm testing. Adding signal handlers that just call exit(1) seems to work fine, though, although it feels kludgey.

Thanks!

Replies are listed 'Best First'.
Re: Re: Re: Destructor Order
by ysth (Canon) on Apr 04, 2004 at 12:02 UTC
    Just switching to use lexicals instead of package variables should avoid global destruction and let your objects be destroyed as their refcounts dictate, e.g.:
    $ perl -w sub DESTROY { warn $_[0]->{name} } my $inner = bless {name => "inner"}; my $outer = bless {name => "outer", inner => $inner}; __END__ outer at - line 1. inner at - line 1.