use 5.010; # need (?(?{ code }) pattern) use Test::More 'no_plan'; use Test::NoWarnings; note 'perl version ', $]; for my $rw ('.+', '.+ w?') { for my $rx ('.+', '.+ x?') { for my $ry ('.+', '(?: . y?)+') { my $captures = qr{ ($rw) ($rx) ($ry) }xms; local our @ra; use re 'eval'; '01234' =~ m{ \A $captures \z # (?(?{ push @ra, [ $1, $2, $3 ] }) (*F) | (*ACCEPT)) (?(?{ push @ra, [ $1, $2, $3 ] }) (*F)) }xms; is_deeply \@ra, [ [ qw(012 3 4) ], [ qw(01 23 4) ], [ qw(01 2 34) ], [ qw(0 123 4) ], [ qw(0 12 34) ], [ qw(0 1 234) ], ], $captures; } # end for $ry } # end for $rx } # end for $rw done_testing;