[...] Perl accepts m'^a$q' which can never match... unless /m is somehow implied [...]With or without the /m modifier, it can never match against any string whatsoever because as the regex is defined, $ is required to match before something other than an end-of-string or newline: 'q' follows it in the regex.
If the regex is defined with a newline to follow the $ metacharacter, if the /m modifier is used and if the interpolation-suppressing ' (single-quote) character is used as the regex delimiter, then a match is possible against a string with an embedded newline:
>perl -wMstrict -le "my $s = qq{a\nq}; print $s =~ m'^a$q' ? ' ' : 'NO ', 'match'; print $s =~ m'^a$q'm ? ' ' : 'NO ', 'match'; print $s =~ m'^a$\nq' ? ' ' : 'NO ', 'match'; print $s =~ m/^a$\nq/m ? ' ' : 'NO ', 'match'; print $s =~ m'^a$\nq'm ? ' ' : 'NO ', 'match'; " NO match NO match NO match NO match match
In reply to Re^2: When exactly do Perl regex's require a full match on a string?
by AnomalousMonk
in thread When exactly do Perl regex's require a full match on a string?
by ELISHEVA
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |