in reply to Word Counting

Update I see you've elaborated above with what you don't know how to do. That's good.

Boy, this sure sounds like homework. Whatever the case, and especially if it is homework, I'd suggest you at least try and write it yourself (it really isn't hard) by following perlplexer's steps. If you still can't manage to do it, come back with code to show and explain what you've tried. Then maybe you'll get better responses.