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


in reply to separate word count for each line of a file

Hint: Coping with Scoping
Sorry if my advice was wrong.