To elaborate a bit what should probably be happening is that the regex engine should always backtrack on .* into the equivalent of NOTHING, but instead it commits to the match and fails under /m once it reaches \n.
perl5.9.5 -Mre=debug -e 'my @re = (qr/.*\z/, qr/.?\z/, qr/(|.+)\z/); "\n" ~~ $_ for @re'
Compiling REx ".*\z"
Final program:
1: STAR (3)
2: REG_ANY (0)
3: EOS (4)
4: END (0)
floating ""$ at 0..2147483647 (checking floating) anchored(MBOL) implicit minlen 0
Compiling REx ".?\z"
Final program:
1: CURLY {0,1} (4)
3: REG_ANY (0)
4: EOS (5)
5: END (0)
floating ""$ at 0..1 (checking floating) minlen 0
Compiling REx "(|.+)\z"
Final program:
1: OPEN1 (3)
3: BRANCH (5)
4: NOTHING (8)
5: BRANCH (FAIL)
6: PLUS (8)
7: REG_ANY (0)
8: CLOSE1 (10)
10: EOS (11)
11: END (0)
floating ""$ at 0..2147483647 (checking floating) minlen 0
Guessing start of match in sv for REx ".*\z" against "%n"
Found floating substr ""$ at offset 0...
Position at offset 0 does not contradict /^/m...
Guessed: match at offset 0
Matching REx ".*\z" against "%n"
0 <> <%n> | 1:STAR(3)
REG_ANY can match 0 times out of 2147483647...
0 <> <%n> | 3: EOS(4)
failed...
failed...
Match failed
Guessing start of match in sv for REx ".?\z" against "%n"
Found floating substr ""$ at offset 0...
Guessed: match at offset 0
Matching REx ".?\z" against "%n"
0 <> <%n> | 1:CURLY {0,1}(4)
REG_ANY can match 0 times out of 1...
0 <> <%n> | 4: EOS(5)
failed...
failed...
1 <%n> <> | 1:CURLY {0,1}(4)
REG_ANY can match 0 times out of 1...
1 <%n> <> | 4: EOS(5)
1 <%n> <> | 5: END(0)
Match successful!
Guessing start of match in sv for REx "(|.+)\z" against "%n"
Found floating substr ""$ at offset 0...
Guessed: match at offset 0
Matching REx "(|.+)\z" against "%n"
0 <> <%n> | 1:OPEN1(3)
0 <> <%n> | 3:BRANCH(5)
0 <> <%n> | 4: NOTHING(8)
0 <> <%n> | 8: CLOSE1(10)
0 <> <%n> | 10: EOS(11)
failed...
0 <> <%n> | 5:BRANCH(8)
0 <> <%n> | 6:PLUS(8)
REG_ANY can match 0 times out of 2147483647...
failed...
1 <%n> <> | 1:OPEN1(3)
1 <%n> <> | 3:BRANCH(5)
1 <%n> <> | 4: NOTHING(8)
1 <%n> <> | 8: CLOSE1(10)
1 <%n> <> | 10: EOS(11)
1 <%n> <> | 11: END(0)
Match successful!
Freeing REx: ".*\z"
Freeing REx: ".?\z"
Freeing REx: "(|.+)\z"