Are you sure you will remember to quadruple your backslashes if you want to match a literal backslash?Sure. But how's that relevant? If I were to write a subpattern that matches a backslash, I may write that as qr/\\/ -- but that doesn't mean that's enough reason to always use qr, even if it's intended to match something different from a backslash.
There is a huge difference between $part = qr/\\d/; and $part = q/\\d/; !I know. Often, both are wrong.
is what's usually intended.$pat1 = '[0-9]'; $pat2 = qr/[0-9]/;
And regarding the speed of constructed pattern ... maybe you stopped one qr// too soon. Instead of building the ultimate pattern at the point it was used, you should have built it just once at the same place you've defined the parts and then used just if ($var =~ $built_regexp) or $var =~ s/$built_regexp/replacement/;I've no clue what you're trying to say.
I haven't seen your code.Indeed.
In reply to Re^7: Common Perl Pitfalls
by JavaFan
in thread Common Perl Pitfalls
by Joe_
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |