|P is for Practical|
Re^4: Problem with input strings that have "" bracketsby afoken (Chancellor)
|on May 09, 2015 at 13:07 UTC||Need Help??|
Just BTW (and it seems to make no difference in my experiments, your Line 7 lacks the closing double-quote found in OP's datum...
No. Everything inside unquoted  inside qr// is a character class. Repeating characters inside  is allowed, but has no effect. Double-quotes have no special meaning there, they are just like almost any other character. In fact, they are the first character only because I sorted all of the characters found in your $pattern line by their ASCII code:
You could move the double quotes to any other position between  without any effect. See Bracketed Character Classes.
have not satisfied myself that I understand the implications of the discussion of 'normaliz(ation) in http://perldoc.perl.org/perlop.html#Regexp-Quote-Like-Operators.
Should not be very relevant here. The most important part (perhaps the only one?) is that RE modifiers are merged into the RE using embedded pattern-match modifiers ((?:pattern), (?adluimsx-imsx:pattern), or (?^aluimsx:pattern) notation):
Enabling newer perl features may add the unicode flag:
See Extended Patterns.
Normalizing does not clean up redundant characters in character classes, nor does it sort characters in character classes - at least not in my perl 5.18.1. Enabling features does not change that. Using qr"" instead of qr// also has no effect:
(Note that ALL of the test patterns match a single character a, b, or c).
There is a difference between $pattern="pattern"; $foo=~/$pattern/, $pattern=qr/pattern/; $foo=~/$pattern/, and $pattern=qr/pattern/; $foo=~$pattern: The first example is simple string interpolation, $pattern is just a simple scalar that will be compiled every time it is used in a regexp. The second and third example creates a Regexp object with a (possibly) compiled regular expression, using it in a regexp avoids recompiling it.
So, qr is not just a quoting operator for regular expressions (despite its name), but a constructor for Regexp (object) references. Those objects stringify to an equivalent (but not necessarily equal) regexp string. Perl may choose to compile the pattern inside the Regexp (object) reference. The exact wording in perlop is "This operator quotes (and possibly compiles) its STRING as a regular expression." in 5.20.1, "A string which is (possibly) interpolated and then compiled as a regular expression." in 5.005.
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)