in reply to Perl bug or feature?
I can confirm this bug is present in 5.12.2 as well.
Running the code with re debugging clearly shows the bug:
There's no way the last match should be /^h(.*)/.Compiling REx "^h(.*)" Final program: 1: BOL (2) 2: EXACT <h> (4) 4: OPEN1 (6) 6: STAR (8) 7: REG_ANY (0) 8: CLOSE1 (10) 10: END (0) anchored "h" at 0 (checking anchored) anchored(BOL) minlen 1 Guessing start of match in sv for REx "^h(.*)" against "http" Guessed: match at offset 0 Matching REx "^h(.*)" against "http" 0 <> <http> | 1:BOL(2) 0 <> <http> | 2:EXACT <h>(4) 1 <h> <ttp> | 4:OPEN1(6) 1 <h> <ttp> | 6:STAR(8) REG_ANY can match 3 times out of 214 +7483647... 4 <http> <> | 8: CLOSE1(10) 4 <http> <> | 10: END(0) Match successful! 'testing' =~ /testing/ at w line 14. Compiling REx "testing" Final program: 1: EXACT <testing> (4) 4: END (0) anchored "testing" at 0 (checking anchored isall) minlen 7 Guessing start of match in sv for REx "testing" against "testing" Found anchored substr "testing" at offset 0... Guessed: match at offset 0 1 at w line 15. Guessing start of match in sv for REx "^h(.*)" against "http" Guessed: match at offset 0 Matching REx "^h(.*)" against "http" 0 <> <http> | 1:BOL(2) 0 <> <http> | 2:EXACT <h>(4) 1 <h> <ttp> | 4:OPEN1(6) 1 <h> <ttp> | 6:STAR(8) REG_ANY can match 3 times out of 214 +7483647... 4 <http> <> | 8: CLOSE1(10) 4 <http> <> | 10: END(0) Match successful! 'testing' =~ // at w line 14. Freeing REx: "testing" Compiling REx "" Final program: 1: NOTHING (2) 2: END (0) minlen 0 Guessing start of match in sv for REx "^h(.*)" against "testing" String not equal... Match rejected by optimizer Warning: something's wrong at w line 15. Guessing start of match in sv for REx "^h(.*)" against "http" Guessed: match at offset 0 Matching REx "^h(.*)" against "http" 0 <> <http> | 1:BOL(2) 0 <> <http> | 2:EXACT <h>(4) 1 <h> <ttp> | 4:OPEN1(6) 1 <h> <ttp> | 6:STAR(8) REG_ANY can match 3 times out of 214 +7483647... 4 <http> <> | 8: CLOSE1(10) 4 <http> <> | 10: END(0) Match successful! 'testing' =~ /testing/ at w line 14. Guessing start of match in sv for REx "^h(.*)" against "testing" String not equal... Match rejected by optimizer Warning: something's wrong at w line 15. Guessing start of match in sv for REx "^h(.*)" against "http" Guessed: match at offset 0 Matching REx "^h(.*)" against "http" 0 <> <http> | 1:BOL(2) 0 <> <http> | 2:EXACT <h>(4) 1 <h> <ttp> | 4:OPEN1(6) 1 <h> <ttp> | 6:STAR(8) REG_ANY can match 3 times out of 214 +7483647... 4 <http> <> | 8: CLOSE1(10) 4 <http> <> | 10: END(0) Match successful! 'testing' =~ /testing/ at w line 14. Guessing start of match in sv for REx "^h(.*)" against "testing" String not equal... Match rejected by optimizer Warning: something's wrong at w line 15. Freeing REx: "^h(.*)" Freeing REx: ""
|
|---|