in reply to Re^5: Try::Tiny and -E
in thread Try::Tiny and -E

Any reason you didn't provide your tests? Because my testing confirms what I said.

$ perl -e' use feature qw( try ); use Try::Tiny; try { }; CORE::say "ok"; ' syntax error at -e line 4, near "};" Execution of -e aborted due to compilation errors.

vs

$ perl -e' use Try::Tiny; use feature qw( try ); try { }; CORE::say "ok"; ' syntax error at -e line 4, near "};" Execution of -e aborted due to compilation errors.

And

$ perl -e' use feature qw( try ); use Try::Tiny; { no feature qw( try ); try { }; } CORE::say "ok"; ' ok

vs

$ perl -e' use Try::Tiny; use feature qw( try ); { no feature qw( try ); try { }; } CORE::say "ok"; ' ok

So I repeat: The order in which they are loaded is irrelevant, and what matters is if the feature is enabled or not when the try is encountered.

Replies are listed 'Best First'.
Re^7: Try::Tiny and -E
by LanX (Saint) on Dec 29, 2025 at 11:56 UTC

      In the OP's example Try::Tiny is activated first and can't know about a later feature.

      I think it can check correctly, but I'm not sure. If it can, it can do so regardless of whether it was loaded first or not. And if it can, it's not trivial.

      More importantly, is it even its job? After all, the following doesn't warn:

      sub print { ... } print ...;

      Maybe this is something Perl::Critic can handle.

        That's because print is a very special beast which allows an unusual print FH @args syntax.

        compare

        ~$ perl use warnings; sub shift {} shift; __END__ Ambiguous call resolved as CORE::shift(), qualify as such or use & at +- line 4. ~$

        Other languages like Javascript block the use of built-ins as function names. This could be a solution for the case print and similar commands.

        Cheers Rolf
        (addicted to the Perl Programming Language :)
        see Wikisyntax for the Monastery