in reply to Do the Monks recommend Try::Tiny for eval work?

Responding because I've linked the docs to the module twice lately. I don't use Try::Tiny (now, I did for awhile). I've just been linking the doc because it's a good overview of problems. I do similar to anonymonk. I didn't know Devel::EvalError either. tye usually knows what he's doing though :P so I'll check it out if I think regular eval{} isn't bringing enough to the table.

Replies are listed 'Best First'.
Re^2: Do the Monks recommend Try::Tiny for eval work? (or do)
by tye (Sage) on Oct 30, 2015 at 02:51 UTC

    Devel::EvalError isn't really needed with a modern version of Perl (where a DESTROY can't clobber $@).

    At work I mostly inherited the following pattern:

    eval { ... 1 } or do { my $e = $@ || 'Unknown error'; ... };

    And I've been pretty happy with it.

    We are still on a Perl version where $@ can be clobbered by a DESTROY, but we just exhaustively fix any DESTROY methods.

    If you have less control over your code base(s) and have to deal with less modern versions of Perl, then Devel::EvalError might be very useful (it was very useful to me at a prior job).

    - tye