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 |