http://www.perlmonks.org?node_id=412915


in reply to Count multiple pattern matches

Try Regexp::List. It converts qw/foobar fooxar foozap fooza/ to qr/foo(?:[bx]ar|zap?)/ using Trie structure so that the resulting regex is much more efficient than naive /foobar|fooxar|.../. And tillys approach to counting each word by capturing the match sounds great.
--kap