From perlre:
WARNING: Once Perl sees that you need one of $&, $`, or $' anywhere in + the program, it has to provide them for every pattern match. This ma +y substantially slow your program. Perl uses the same mechanism to pr +oduce $1, $2, etc, so you also pay a price for each pattern that cont +ains capturing parentheses. (To avoid this cost while retaining the g +rouping behaviour, use the extended regular expression (?: ... ) inst +ead.) But if you never use $&, $` or $', then patterns without captur +ing parentheses will not be penalized. So avoid $&, $', and $` if you + can, but if you can't (and some algorithms really appreciate them), +once you've used them once, use them at will, because you've already +paid the price.
I don't see why they had to make it set them on *every* regex match just because one uses them. Why couldn't they just add a new modifier (like /i, /x, /g, etc), and only set them if the modifier is used?

--MrNobo1024
s]]HrLfbfe|EbBibmv]e|s}w}ciZx^RYhL}e^print


In reply to Why can't $` $& $' be enabled on a per-regex basis? by MrNobo1024

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.