Regarding 1st solution: Since this code is used to implement pseudo-vars that can be initialized and checked at compile time, inserting an layer of callsub *seems* like a high penalty to pay.

I tried using the "for" as a $_ specifier, but as soon as it was in the goto-target-func, the value was restored to the one in the outer loop.

The Internals fix looks like the right way to solve this, as it addresses the problem. However, I solved it by making use of a global, as it's less likely to break. With the current maintainers, the perl feature set is unstable (they yanked lexical $_ out of feature status and into experimental status in 5.18, and forced in a new feature that affects everyone in 5.18 without opting in (via "use 5.18" or use feature "xxx"). Releasing incompatible features in the production version of perl demonstrates their level of commitment to stable interfaces. Heaven knows what they would do to the Internal interfaces.

Didn't know "lvalue" was also experimental until last week -- as when I started using it, I followed its usage example in some CPAN code ... urg...


In reply to Re^2: How to safely use $_ in a library function? by perl-diddler
in thread How to safely use $_ in a library function? by perl-diddler

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.