in reply to Help with accepting inputs, wordcount, and print to a file

You could split your $line string on whitespace, then accumulate the results in a hash. The hash would store the counts of each word.

Look at perldoc -f print to see how to print to a file (or just redirect the output in your shell).

See also: