in reply to seeking eval failures
The question is: it is easy to have an eval succeed (hence setting $@ and return undef, but is it possible to have a failing eval to return a null $@?
Yes and no.
You cannot get $@ set to an actual null string. If you die with '' it will get the filename and line number info appended - just like any other die with a string sans trailing "\n".
As broquaint points out you can die with an error object that evaluates to false. However, this is (technically) not a null string.
If you really want to be sure an exception was thrown do:
if( ref($@) || $@ ne '' ) { ... handle exception ... }
But this is almost always overkill, unless you expect to be dealing with broken exception mechanisms. I've never come across a false exception that hasn't been a bug.
|
|---|