my @s; # string array my @r; # regex array my %m; # matches hash %m = map { my $k = $_; $_, { map { my $s =()= $k=~/$_/g; $_,$s } @r }; } @s;