in reply to Re^5: Wierd bugs I would have never expected
in thread Wierd bugs I would have never expected
I wouldn't call it a change because eval blocks can have return statements in 5.8.8 as well which is where this "issue" (call it what you will) was found. I use returns in eval blocks all the time, in this idiom:
<c>eval { ... something that can die ... #insures we never go into the do block except when we die return 1; } or do { my $e=$@; #the exception ... exception handling here ... };
That odd bit of code is needed because destructors can clear $@ so there are times when a routine dies but $@ is undefined or ''. On the otherhand, an eval block is guarenteed to return undef if it dies an unnatural death. Thus with the above idiom we can be sure that we will enter the do block if and only if the eval block dies before its time.
I would probably add the disappearing exception ($@ being cleared) to my list of odd and hard to track down bugs. It is easy to overlook it as a possiblity unless of course you are "in the know" that such things like disappearing exceptions can happen. Most tutorials on exceptions teach people to capture failure like this eval {...}; if ($@) {...} but if you use that idiom, the exception handling code will never be reached should something wipe out $@.
|
|---|