in reply to Counting matches

Applying each regex in one array to each string in another array:

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

The =()= thingy? It forces list context on the right hand side and returns the number of elements of that list for a scalar on the left hand side, if the left hand side is a scalar. See also Re: Hidden features of Perl (More Secret Operator References)

For

counts the number of times that each string in one array matches a regex containing that string in another array

which I read as matching the regex against the string, just swap the arrays.

perl -le'print map{pack c,($-++?1:13)+ord}split//,ESEL'