##
sub countOverlappingMatches
{
my $stringRef = shift; #Likely to be huge, don't make a copy
my $patternRef = shift;
my $count =()= $$stringRef =~ /(?=$$patternRef)/g;
return $count;
}
print countOverlappingMatches(\'abrabrabrabra', \'rabra'); # 3
####
for my $pattern (@listOfPatterns)
{
my $count =()= $string =~ /(?=$pattern)/g;
# Play with $count
}