go ahead... be a heretic | |
PerlMonks |
Re: canonical doc explaing need for "eval { ... } or do {...}" constructby ikegami (Patriarch) |
on May 11, 2022 at 14:18 UTC ( [id://11143794]=note: print w/replies, xml ) | Need Help?? |
Since 5.28, it doesn't matter. Before, especially before 5.14, $@ could get clobbered, so if eval { ... ; 1 } was more reliable. There was a time where it was possible for $@ to get cleared or replaced before eval returned.
This has been fixed.
So, using eval { ...; 1 } and checking the result of eval was more reliable. And it was promoted as the more reliable solution for this reason. There was an attempt to fix in 5.14, but edge cases were only fixed in 5.28. Updated to cover edge cases found later, as per choroba's reply.
In Section
Seekers of Perl Wisdom
|
|