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

Two options come to mind. Either or neither may be useful. First, make sure you destroy all references to your object before you exit. If you can keep track of that, great. (Perl 5.6 has support for weak references that can help.)

Otherwise, you might have to add a separate not-quite-destructor phase. In Jellybean, anything that needs to shut down cleanly is expected to have a method named _cleanup(). When the Engine shuts down, it calls _cleanup() on the parent Container. Containers call this on all of their children.

If we could count on an order of destruction at the end of the program, this wouldn't be necessary. It's a small price to pay for reliable semantics, though.

  • Comment on Re: How can I call other objects from my object during DESTROY