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


in reply to Printing the count for regex matches

Declare @match before the loop (so that it is not overwritten each time), append any matches to @match, and move the print statement outside the while loop.

And you didn't even know bears could type.