m Treat string as multiple lines. That is, change "^" and "$" from
matching the start or end of the string to matching the start or
end of any line anywhere within the string.
####
$ perl -Mre=debug -wle'"ABC\nDEF" =~ m/C(?:$)^D/m'
Freeing REx: `","'
Compiling REx `C(?:$)^D'
size 7 Got 60 bytes for offset annotations.
first at 1
rarest char D at 1
1: EXACT (3)
3: MEOL(4)
4: MBOL(5)
5: EXACT (7)
7: END(0)
anchored "CD" at 0 (checking anchored) minlen 2
Offsets: [7]
1[1] 0[0] 5[1] 7[1] 8[1] 0[0] 9[0]
Omitting $` $& $' support.
EXECUTING...
Guessing start of match, REx "C(?:$)^D" against "ABC
DEF"...
Did not find anchored substr "CD"...
Match rejected by optimizer
Freeing REx: `"C(?:$)^D"'
####
$ perl -Mre=debug -wle'"ABC\nDEF" =~ m/C(?:$)$\?^D/m'
Freeing REx: `","'
Omitting $` $& $' support.
EXECUTING...
Compiling REx `C(?:$)
?^D'
size 11 Got 92 bytes for offset annotations.
first at 1
rarest char D at 0
rarest char C at 0
1: EXACT (3)
3: MEOL(4)
4: CURLY {0,1}(8)
6: EXACT <\n>(0)
8: MBOL(9)
9: EXACT (11)
11: END(0)
anchored "C"$ at 0 floating "D" at 1..2 (checking floating) minlen 2
Offsets: [11]
1[1] 0[0] 5[1] 8[1] 0[0] 7[1] 0[0] 9[1] 10[1] 0[0] 11[0]
Guessing start of match, REx "C(?:$)
?^D" against "ABC
DEF"...
Found floating substr "D" at offset 4...
Found anchored substr "C"$ at offset 2...
Starting position does not contradict /^/m...
Guessed: match at offset 2
Matching REx "C(?:$)
?^D" against "C
DEF"
Setting an EVAL scope, savestack=6
2 | 1: EXACT
3 <
DEF> | 3: MEOL
3 <
DEF> | 4: CURLY {0,1}
EXACT <\n> can match 1 times out of 1...
Setting an EVAL scope, savestack=6
4 | 8: MBOL
4 | 9: EXACT
5 | 11: END
Match successful!
Freeing REx: `"C(?:$)\n?^D"'