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

Not sure what you are objecting about, the newest feature has code examples showing how an import() of a module can check the hinthash of the caller.

Try::Tiny or others could do this too, if they come second.

From feature_enabled($feature, $depth)

package MyStandardEnforcer; use feature (); use Carp "croak"; sub import { croak "disable indirect!" if feature::feature_enabled("indirect"); }

And yes, the implementation of feature_enabled() is in pure Perl.

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

Replies are listed 'Best First'.
Re^8: Try::Tiny and -E
by ikegami (Patriarch) on Dec 30, 2025 at 00:04 UTC

    That solution will give both false positives (warn when it shouldn't) and false negatives (not warn when it should). The order loaded will determine if you can get false positives or false negatives, but it you can get false results regardless of the order in which they are loaded. Again, the order in which you load the modules is irrelevant. And that's because you're checking at the wrong time to get consistent results. For that, you need to check when try use is compiled, not when the module is loaded.

      > For that, you need to check when try use is compiled,

      What do you mean?

      > That solution will give both false positives (warn when it shouldn't) and false negatives (not warn when it should).

      Please elaborate or demonstrate those cases.

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

        What do you mean?

        use feature qw( try ); is a lexically-scoped pragma. The only thing that matter is the hints in effect when the try word is being compiled.

        Please elaborate or demonstrate those cases.

        I already posted the test cases.