BeneSphinx has asked for the wisdom of the Perl Monks concerning the following question:
This performs about as I "wanted" i.e. that it matches the $hello string, but I'm still a little confused as to why. From my reading of the Perl docs I know there are two passes: a limited double quote parsing followed by a regular expression interpretation. I would expect that in the first pass, those characters would be converted to their "real" forms, like actual newlines and tabs, and the backslash simply removed from before the pipe. However, it seems this isn't happening. So, does that mean that the only form of interpretation in the first pass is to interpolate variables, or is there anything else? Thanks for your clarification.use strict; use warnings; my $hello = "\n |\t\r"; if ($hello =~ m/^[ \|\t\r\n]+$/){ print "yep this matches"; } else { print "no this doesn't match"; } exit;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: left side of pattern matching
by jwkrahn (Abbot) on Mar 13, 2012 at 16:48 UTC | |
|
Re: left side of pattern matching
by dave_the_m (Monsignor) on Mar 14, 2012 at 00:13 UTC | |
|
Re: left side of pattern matching
by LanX (Saint) on Mar 13, 2012 at 17:34 UTC | |
|
Re: left side of pattern matching
by furry_marmot (Pilgrim) on Mar 13, 2012 at 20:13 UTC |