Perl's block eval is not string eval. Quoting from 'perldoc -f eval':
In the second form, the code within the BLOCK is parsed only
once--at the same time the code surrounding the "eval" itself
was parsed--and executed within the context of the current Perl
program. This form is typically used to trap exceptions more
efficiently than the first (see below), while also providing
the benefit of checking the code within BLOCK at compile time.
The only (significant) questionable decision there is the name; its functionality is the same as 'try' in other languages. There are some issues, however, with properly dealing with failures in an eval block. They're fairly obscure, and won't often come up, but they're explained in the "Background" section of the Try::Tiny docs: http://search.cpan.org/~doy/Try-Tiny-0.09/lib/Try/Tiny.pm#BA...
Try::Tiny is a minimal module with no dependencies that does the least amount necessary to get 'try' and 'catch' keywords into the language, connecting handler blocks to guarded blocks. There are some problems with this, like trying to use loop control or return statements inside of a catch block. The normal way to get good error handling that deals with all of the potential issues without introducing others is TryCatch, which also adds extra features, like Moose type constraints on multiple catch blocks: http://search.cpan.org/~ash/TryCatch-1.003000/lib/TryCatch.p...
Try::Tiny is a minimal module with no dependencies that does the least amount necessary to get 'try' and 'catch' keywords into the language, connecting handler blocks to guarded blocks. There are some problems with this, like trying to use loop control or return statements inside of a catch block. The normal way to get good error handling that deals with all of the potential issues without introducing others is TryCatch, which also adds extra features, like Moose type constraints on multiple catch blocks: http://search.cpan.org/~ash/TryCatch-1.003000/lib/TryCatch.p...