Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Bug in eval in pre-5.14

by zwon (Abbot)
on Jan 25, 2016 at 22:44 UTC ( #1153620=note: print w/replies, xml ) Need Help??


in reply to Bug in eval in pre-5.14

Note that Try::Tiny doesn't provide more than the "or do" pattern
It actually does, it preserves the value of $@, the following modifications to your script demonstrate the difference:
...; eval { die "Foo!" }; # Exception details lost. eval { my $o2 = 'My::Obj'->new; die "Exception!"; 1 } or do { warn "Caught with or: $@"; }; say "\$\@ after eval or do: $@"; # not same as above. use Try::Tiny; eval { die "Foo!" }; try { my $o3 = 'My::Obj'->new; die "Exception!"; } catch { warn "Caught with Try::Tiny: $_"; }; say "\$\@ after try catch: $@";

Replies are listed 'Best First'.
Re^2: Bug in eval in pre-5.14
by choroba (Archbishop) on Jul 14, 2016 at 15:57 UTC
    Solvable by localizing $@:
    eval { die "Foo!" }; # Exception details not lost. { local $@; eval { my $o2 = 'My::Obj'->new; die "Exception!"; 1 } or do { warn "Caught with or: $@"; }; } warn "\$\@ after eval or do: $@";

    ($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1153620]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (5)
As of 2020-05-29 20:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    If programming languages were movie genres, Perl would be:















    Results (171 votes). Check out past polls.

    Notices?