I don't think that you can trap other constant modules with a block eval either. The issue lies with Perl, which doesn't allow a function/subroutine on the left-hand side of an assignment, unless that function is already known as assignable through the :lvalue attribute:
> perl -wle "sub foo {}; eval { foo()='baz' }" Can't modify non-lvalue subroutine call in scalar assignment at -e lin +e 1, near "'baz' }" Execution of -e aborted due to compilation errors.
Marking the subroutine with :lvalue lets Perl know that we intend to let the function appear on the left-hand side of an assignment:
> perl -wle "sub foo:lvalue {}; eval { foo()='baz' }"
All "constant" modules are syntactic sugar for defining functions that take no parameters, because that's how sigil-less constants work in Perl.
In reply to Re^3: Eval not trapping fatal error
by Corion
in thread SOLVED: Eval not trapping fatal error
by Ea
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |