For me, it's the other way around. For the majority of the (sub)patterns (even with most uses of backslashes), it doesn't matter whether you write q{PAT} or qr{PAT} (it's the same keystrokes inside the braces). Meaning, there's absolutely nada difference in readability.

Why go for the expensive solution? If your pattern grows, at what moment do you revisit your program, and chop off the r in qr?

It's not that I never use qr. Sometimes, there's a (sub)pattern that's more readable as qr than as q. And sometimes, one does want a first class regexp construct. But those are the exceptions.

Do note that using q building blocks to build your patterns gives you more flexibility than limiting yourself to just qr:

my $vowels = 'aeiou'; my $odds = '13579'; my $odd_or_vowel = '[$vowels$odds]';
To write that as qr, you'd have to write something like:
my $vowels = qr/[aeiou]/; my $odds = qr/[13579]/; my $odd_or_vowel = qr/$vowels|$odds/;
which, while matching the same language, throws off the optimizer, and makes not only for a slower compilation, the match itself is slower.

In reply to Re^11: Common Perl Pitfalls by JavaFan
in thread Common Perl Pitfalls by Joe_

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.