shouldn't the pre-compiled regex run faster because of pre-compilation
  1. Both your regexp and your program are fairly trivial. Even if there wasn't any caching involved for non-precompiled regexes, I doubt you'd notice the difference. Whether that's the case for your real $text, I do not know.
  2. Perl has been caching compiled patterns since the 20th century. (5.004 or 5.005, IIRC). This is why /o is usually pointless (if not broken).
  3. Often, the compilation time is dwarved by the runtime anyway.
  4. You'd have to be careful -- if you interpolate your compiled pattern into a larger one, you're paying the price of compilation twice.

In reply to Re^3: Problem with pre-compiled regex by JavaFan
in thread Problem with pre-compiled regex by saranrsm

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.