in reply to Re^2: Try::Tiny and -E
in thread Try::Tiny and -E
Ways to address this:
You can convert to using the builtin feature.
$ perl -E'try { 1/0 } catch ( $e ) { }; say "ok"' # Using 5.40 ok
You can follow add no feature qw( try );
$ perl -MTry::Tiny -E'no feature qw( try ); try { 1/0 }; say "ok"' ok
You can use an older version of the "language" (even if you're using the 5.40 interpreter).
$ perl -Mv5.38 -MTry::Tiny -e'try { 1/0 }; say "ok"' ok
(5.10 would suffice for this program.)
As you might have noticed, -E isn't forward compatible. Your program would have worked with 5.38, but it doesn't with 5.40. If it's not a throwaway program, it's safer to use
or-e'use v5.xx; ...'
instead of-Mv5.xx -e'...'
-E'...' # XXX Not forward-compatible.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Try::Tiny and -E
by atcroft (Abbot) on Dec 30, 2025 at 01:42 UTC | |
|
Re^4: Try::Tiny and -E
by 1nickt (Canon) on Dec 29, 2025 at 11:31 UTC |