in reply to Re: differences between parsing qr, qq, and q string contents
in thread differences between parsing qr, qq, and q string contents

If you have a group of regex's that you're putting together, it is better to use qr{} instead of using q{} or qq{}. This is because you want to validate each subexpression before it's put into your final regex.
But that limits you to using parts that are full patterns themselves.
Getting an error message early on is worth the cost of having to compile the subexpressions once each.
So, it's ok to pay a price each and every time code is compiled, just so *debugging* during development may become easier? It also means you're paying the price if you do know your patterns, and write them correct the first time.

It's not a trade-off I will always make in the same direction. In fact, I'd usually make it in the opposite direction than you suggest should always be taken.

  • Comment on Re^2: differences between parsing qr, qq, and q string contents

Replies are listed 'Best First'.
Re^3: differences between parsing qr, qq, and q string contents
by wind (Priest) on May 02, 2011 at 02:17 UTC
    So, it's ok to pay a price each and every time code is compiled, just so *debugging* during development may become easier? It also means you're paying the price if you do know your patterns, and write them correct the first time.

    It's a very small price to pay.

    And it's not a price at all if you're using mod_perl and so compile time is not a consideration.

    And if it is a price, then just change your qr{}'s to qq{}'s and done.

      It's a very small price to pay.
      I've already indicated that my experience that sometimes, the price isn't small.
      And if it is a price, then just change your qr{}'s to qq{}'s and done.
      That isn't so easy. Changing qr{$foo\d} to qq{$foo\d} isn't going to work.

      But if it's so easy, you could start with qq{}, and change to qr{} only if you cannot debug your errors. Which would require no changes if you did things correctly the first time.