eff_i_g has asked for the wisdom of the Perl Monks concerning the following question:

Monks,

Is there a regexy way to array named captures that are within quantified parentheses?

The first section of code is what I tried, and the second is something I threw together to achieve what I'm after. Should I stick with this, or is there some way to incorporate this into a single regex?

Code:
use Data::Dumper; use Hash::Merge qw(merge); ### 1 ### '1a2b3c' =~ /(?:(?<digit>\d)(?<letter>[a-z]))+/; print Dumper(\%-); ### 2 ### my %match; while ('1a2b3c' =~ /\G(?<digit>\d)(?<letter>[a-z])/gc) { %match = %{ merge(\%match, \%-) }; } print Dumper(\%match);
Output:
$VAR1 = { 'digit' => [ '3' ], 'letter' => [ 'c' ] }; $VAR1 = { 'digit' => [ '1', '2', '3' ], 'letter' => [ 'a', 'b', 'c' ] };