for my $pattern (@listOfPatterns) { my $count =()= $string =~ /(?=$pattern)/g; # Play with $count }