W
Wolfgang Thomas
Hi,
I am afraid that this question has been asked before, but I could not
find the answer in the FAQ nor in the "Programming Perl" book, nor by
googling.
My question refers to the /m modifier for regular expressions.
According to "Programming Perl" /m lets ^ and $ match next to new lines
within the string instead of considering only the beginning and end of
the string.
Therefore I wonder why the following example does not match:
my $s = "123\n456";
if ($s =~ /3$^4/m) {print "match (4)\n";}
Even more confusing (for me) is that
if ($s =~ /3$4/m) {print "match (2)\n";}
matches, whereas
if ($s =~ /34/m) {print "match (3)\n";}
does not match.
Could someone please point me to an explanation of that behavior?
I am afraid that this question has been asked before, but I could not
find the answer in the FAQ nor in the "Programming Perl" book, nor by
googling.
My question refers to the /m modifier for regular expressions.
According to "Programming Perl" /m lets ^ and $ match next to new lines
within the string instead of considering only the beginning and end of
the string.
Therefore I wonder why the following example does not match:
my $s = "123\n456";
if ($s =~ /3$^4/m) {print "match (4)\n";}
Even more confusing (for me) is that
if ($s =~ /3$4/m) {print "match (2)\n";}
matches, whereas
if ($s =~ /34/m) {print "match (3)\n";}
does not match.
Could someone please point me to an explanation of that behavior?