If I put the for-loop back into the unrolled loop code, I start to see weird stuff again (still Strawberry 5.14.4.1):
c:\@Work\Perl\monks>perl -wMstrict -le
"for my $string (qw(ab1b2b3b4d ab5b6b7d ab8b9d abxd ad)) {
my @two;
my @matches = $string =~ /(a)
(?: (b.) (?{ push @two, $2 }))+
(d)/x;
print qq{'$string' -> all:(@matches) -> 2:(@two)};
}
"
'ab1b2b3b4d' -> all:(a b4 d) -> 2:(b1 b2 b3 b4)
'ab5b6b7d' -> all:(a b7 d) -> 2:()
'ab8b9d' -> all:(a b9 d) -> 2:()
'abxd' -> all:(a bx d) -> 2:()
'ad' -> all:() -> 2:()
What Perl version are you using?
Give a man a fish: <%-{-{-{-<