>perl -wMstrict -le "for (<>) { /(\w+)/; $::i{$1}++ } print qq{$_ $::i{$_}} for keys %::i " words2.txt bar 2 baz 2 qux 2 foo 3