in reply to Count multiple pattern matches

Have you tried to insert a study $string; outside the loop, before you do the first regex match? This should speed up the matches, especially if $string is very long.
perldoc -f study
for more information.