in reply to Testing a module with eval() where $@ is clobbered (pre v5.14)

What your module code definitely shouldn't be doing is the unfortunately common but wrong idiom eval {...}; if ($@) {handle_error} - instead, you should do something like eval { ...; 1 } or handle_error;. If you're doing the former in your module, then you need to change the module code.

That gives you reliable detection of errors, and other than that, you could customize your tests to not check the contents of $@ pre-5.14. (Also, I seem to remember some long-standing issues with $SIG{__DIE__} inside of evals, so be careful with that too. And also IIRC even post-5.14 some smaller issues with $@ remained, so to say that $@ now works perfectly isn't quite correct either. Lazy Sunday, so I don't have the references for both issues handy at the moment...)

Replies are listed 'Best First'.
Re^2: Testing a module with eval() where $@ is clobbered (pre v5.14)
by Anonymous Monk on Jan 17, 2016 at 11:50 UTC

    Found 'em. RT#123738, RT#123773, and perlvar:

    Due to an implementation glitch, the $SIG{__DIE__} hook is called even inside an eval(). Do not use this to rewrite a pending exception in $@, or as a bizarre substitute for overriding CORE::GLOBAL::die(). This strange action at a distance may be fixed in a future release so that $SIG{__DIE__} is only called if your program is about to exit, as was the original intent. Any other use is deprecated.