in reply to Regex dynamics

... or just use Regexp::Common e.g
while( /(\w{1,2})$RE{balanced}{-parens=>"[]"}{-keep}/ ) { push @{ $hash{$1} }, substr($2, 1, length($2) - 2); }
HTH

_________
broquaint