you are wrong on both accounts.

> It doesn't matter when the Try::Tiny is compiled.

I've explicitly tested this with feature::feature_enabled() and order definitely matters.

It's basically the difference between:

use feature "try"; use Try::Tiny;

vs

use Try::Tiny; # no chance (well see footnote°) use feature "try";

And that's because lexical scope starts right at the point of declaration.

> it's out of reach of Try::Tiny since I believe it's intentionally a pure-Perl module.

It's very much possible with a pure-Perl module like I said. The _enabled routines in feature are basically checking the hinthash %^H returned by caller for the needed level.

And the hint-key is called "feature_try"

A slight complication is that feature introduced "try" before it provided the check-enabled routines. IOW one needs to copy the hint-hash lookup logic for older Perl versions.

Footnotes

°) the wrong order could be fixed by using an INIT {} block doing the check after all compilations are completed, but I question the wisdom of such a fragile construct. Too many edge cases.¹

¹) Turns out that neither INIT,CHECK or UNITCHECK can see the hint anymore.

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

update

little demo v5.38

perl -E'BEGIN{say join "\n",feature::features_enabled()}' bareword_filehandles bitwise current_sub evalbytes fc indirect isa module_true multidimensional postderef_qq say signatures state unicode_eval unicode_strings

In reply to Re^5: Try::Tiny and -E by LanX
in thread Try::Tiny and -E by 1nickt

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.