in reply to Is there a way to know why the DESTROY method was invoked?
A better question I should be asking is "Why do you need to know?" Is this just for near-term debugging purposes or do you intend to use this in production code? All of the ways I can think of implementing this involve introducing either unnecessarily complicated code or significant potential for spooky action-at-a-distance bugs. Both of these result in maintenance and code-reuse headaches.
Caveats aside, one fairly straightforward way to do this would be to set either a module variable or global variable in a signal handler so you can test in DESTROY if die was called. See die and %SIG for information on setting $SIG{__DIE__}.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Is there a way to know why the DESTROY method was invoked?
by erabus (Sexton) on Feb 18, 2010 at 18:11 UTC | |
by ikegami (Patriarch) on Feb 18, 2010 at 18:24 UTC | |
|
Re^2: Is there a way to know why the DESTROY method was invoked?
by ikegami (Patriarch) on Feb 18, 2010 at 18:04 UTC |