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

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.

Replies are listed 'Best First'.
Re^9: Try::Tiny and -E
by LanX (Saint) on Dec 30, 2025 at 03:10 UTC
    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

      But so is try.

      The difference between print and shift is that print can't be prototyped. The same goes for try since it's not even a function but a keyword like while.

      $ perl -Mv5.40 -e'say prototype "CORE::$ARGV[0]" // "[undef]"' shift ;\@ $ perl -Mv5.40 -e'say prototype "CORE::$ARGV[0]" // "[undef]"' print [undef] $ perl -Mv5.40 -e'say prototype "CORE::$ARGV[0]" // "[undef]"' try [undef]