in reply to Re: capturing multiple repeated regex subparts
in thread capturing multiple repeated regex subparts

Don't eschew $^R! That's what it's there for:
# UPDATED: added comments about what's going on our @rv; # you like taking trips? ;) m{ (text); # the (?{ ... }) block's return value # is given to $^R, the magical variable # whose value is auto-localized and gets # rolled back when backtracking occurs. # $^R's initial value, then, is an array # ref with one element, $1's value. (?{ [$1] }) (?: (float) # then, four times, we add the float we # match in $2 to the end of $^R. we # can't just do push(@{$^R}, $2), because # that would break the auto-rollback magic, # so instead, we just let the return value # set $^R again. (?{ [ @{$^R}, $2 ] }) non-num ){4} # finally, we store @{$^R} in @rv. (?{ @rv = @{$^R} }) }x;

Jeff japhy Pinyan, P.L., P.M., P.O.D, X.S.: Perl, regex, and perl hacker
How can we ever be the sold short or the cheated, we who for every service have long ago been overpaid? ~~ Meister Eckhart