in reply to Re^4: reg. expr. multiple substitutions
in thread reg. expr. multiple substitutions

I wasn't talking about performance. If you are going to re-interpolate a qr// compiled regex, whatever escapaing might be required had you not used qr//, would still be required. Either manually, or via quotemeta. Ergo, the qr// would buy you nothing.


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

The start of some sanity?

  • Comment on Re^5: reg. expr. multiple substitutions

Replies are listed 'Best First'.
Re^6: reg. expr. multiple substitutions
by dave_the_m (Monsignor) on May 17, 2012 at 16:01 UTC
    whatever escapaing might be required had you not used qr//, would still be required
    Not completely. First off, if a regex $r is used as the *only* part of a pattern in /$r/ or s/$r/../, then it is not interpolated, but used as is. Secondly, by using a regex literal rather than a string literal, you get backslashed things handled right:
    $r = qr/\bfoo/; /$r/; # matches word boundary $r = "\bfoo"; /$r/; # matches backspace
    (Although this is mostly moot, since as was pointed out elsewhere, hash keys are stored as strings.)

    Dave.

      if a regex $r is used as the *only* part of a pattern in /$r/ or s/$r/../, then it is not interpolated, but used as is.

      That's information that I've never seen written down before. Thank you.


      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.

      The start of some sanity?