in reply to Re^10: Reusing a complex regexp in multiple spots, escaping the regexp
in thread Reusing a complex regexp in multiple spots, escaping the regexp

You are showing a semantic where /o MUST NOT be applied. Obviously you shouldn't inhibit recompilation if you need recompilation.

One of the links sleet listed upthread (or the docs🤔) were explicit that /o would inhibit any recompilation of the regex even with nested variables, hence solving the performance issue in a loop.

> perldoc perlre does note that /o is pretty broken

Dunno, a literal quote would be helpful.

A concrete test - probably with re debug - even more. :)

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

  • Comment on Re^11: Reusing a complex regexp in multiple spots, escaping the regexp
  • Download Code

Replies are listed 'Best First'.
Re^12: Reusing a complex regexp in multiple spots, escaping the regexp
by tobyink (Canon) on Apr 17, 2026 at 08:15 UTC

    Dunno, a literal quote would be helpful.

    Substitution-specific modifiers described in "s/PATTERN/REPLACEMENT/ms +ixpodualngcer" in perlop are: e - evaluate the right-hand side as an expression ee - evaluate the right side as a string then eval the result o - pretend to optimize your code, but actually introduce bugs r - perform non-destructive substitution and return the new value
        > The longest explanation of /o

        This covers exactly my understanding.

        You'll also find this in perlop for m//

        - "But now, the only reasons to use /o are one of:..."

        The perldocs are vast and often redundant, and sometimes contradictory.

        They are like much of the code base a collaborative design.

        The wording at perlre is at best dubious and as far as I can see not substationated.

        As long as nobody shows me a real bug caused by /o I'd call this BS.

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

      I did some research and couldn't find a bug introduced by /o.

      Please demonstrate one, which is not just someone complaining that it acts differently, or misunderstood the o for optimize instead of once.

      It's like complaining about state being buggy since it acts differently to my ...

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

        It's like complaining about state being buggy since it acts differently to my ...

        Indeed, that's exactly what it is. Why it could be considered buggy in the case of "/o" though is that it's poorly documented, rarely desired, and very easy to miss when debugging because it's a single character often hidden away in the middle of or at the end of an expression, instead of a full keyword at the start of statement like state.