in reply to Re: Rethrowing with die $@ considered harmful
in thread Rethrowing with die $@ considered harmful

This was a nightmare to track down. The solution was to simply localise $@ in the destructor.

Yeah, side effects and destructors don't mix well accoding to perlobj...

Since DESTROY methods can be called at unpredictable times, it is important that you localise any global variables that the method may update. In particular, localise $@ if you use "eval {}" and localise $? if you use "system" or backticks.

You can see where I got bit by this a few years ago here Devious Destructor. It would be nice if perl did this for you (but perhaps it can't?) since sometimes it's not obvious that what you are calling is altering globals, and it's not easy to remember to do this.