in reply to a question about making a word frequency matrix
example, to count the number of instances of each word in a file you could use split/\W/ in the place of split/WHATEVER/ or just split if you wanted to keep punctuation,etc. intact. output is ordered by most frequent occurrences (at the top of the "item:count\n" listing)perl -nle '$c{$_}++ for split/\s/;}print map {"$_:$c{$_}\n"} sort{$c{$ +b}<=>$c{$a}}keys %c;{' file_of_WHATEVER_to_count.txt
|
|---|