They are partly based on a talk I did at the German Perl Workshop 2008, see my talk in german.
How does the regex
m/foo$\nbar/mgets interpreted?
At first it looks like it matches "foo", then end of line with the $, then a newline with \n and finally "bar".
Let' see:
my $string = "foo\nbar";Surprisingly the regex does not match like expected.
print $string =~/foo$\nbar/m ? 'match':'no match'
Explanation:
The regex is interpreted as
/foo $\ nbar/mxe.g. it matches "foo", then the content of the special variable $\ (usually undef) and finally "nbar"
Keine Kommentare:
Kommentar veröffentlichen