in reply to Re: eval: Why use the 'Zombie error' idiom?
in thread eval: Why use the 'Zombie error' idiom?

...So, would local-izing $@ be enough to work-around other code's evals messing with our own $@?
{ # scope the `local` local $@; eval { do_something_that_might_die(); 1; } or do { my $error = $@; ## ?? No need for || 'Zombie error' ?? deal_w($error) || die; } }

Replies are listed 'Best First'.
Re^3: eval: Why use the 'Zombie error' idiom?
by hippo (Archbishop) on Oct 18, 2019 at 10:45 UTC

    The docs for eval suggest this idiom:

    # alter $@ on nefarious repugnancy only { my $e; { local $@; # protect existing $@ eval { test_repugnancy() }; # $@ =~ /nefarious/ and die $@; # Perl 5.14 and higher only $@ =~ /nefarious/ and $e = $@; } die $e if defined $e }
Re^3: eval: Why use the 'Zombie error' idiom?
by Corion (Patriarch) on Oct 18, 2019 at 10:04 UTC

    I don't know - from the discussion in Try::Tiny, it sounds like that, but then, the code of Try::Tiny isn't really that large either. So maybe looking there (or in its test suite) helps find the nasty edge cases.