Если вы добавите re в свой код:
use re 'debug';
, вы увидите, что регулярное выражение успешно совпадает дважды:
Compiling REx `.*'
size 3 Got 28 bytes for offset annotations.
first at 2
1: STAR(3)
2: REG_ANY(0)
3: END(0)
anchored(MBOL) implicit minlen 0
Offsets: [3]
2[1] 1[1] 3[0]
Matching REx ".*" against "a"
Setting an EVAL scope, savestack=5
0 <> <a> | 1: STAR
REG_ANY can match 1 times out of 2147483647...
Setting an EVAL scope, savestack=5
1 <a> <> | 3: END
Match successful!
Matching REx ".*" against ""
Setting an EVAL scope, savestack=7
1 <a> <> | 1: STAR
REG_ANY can match 0 times out of 2147483647...
Setting an EVAL scope, savestack=7
1 <a> <> | 3: END
Match successful!
Matching REx ".*" against ""
Setting an EVAL scope, savestack=7
1 <a> <> | 1: STAR
REG_ANY can match 0 times out of 2147483647...
Setting an EVAL scope, savestack=7
1 <a> <> | 3: END
Match possible, but length=0 is smaller than requested=1, failing!
failed...
Match failed
foofoo
Freeing REx: `".*"'