For regexes with variables in them, it rebuilds the machine every time it uses the regex.

IIRC it's long since this is not the case anymore. Perl's checking a regex-cache to see if it has already compiled the pattern. That's why the /o flag is almost useless now (Beware: it can produce ugly side effects if not used with care)

(Though I couldn't find it stated in the perldocs :-( ... I think I should have read it in Friedl's regex "bible")

As Ikegami already suggested, stick with qr is certainly the cleanest approach to control compilation time, even with nested regexes, so better just forget /o! ¹

Cheers Rolf

UPDATE:

(1) or better only try to remember it as a possible optimization AFTER profiling shows a bottleneck!


In reply to Re: Optimize a pluggable regex matching mechanism (/o practically deprecated) by LanX
in thread Optimize a pluggable regex matching mechanism by dredd

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.