0: Not a particularly useful program, but I had an assignment
1: a while back in a class to write a program in the language
2: of our choice to count the words in a text file, and print
3: out the 10 most commonly used words. It's not very fast,
4: not very efficient, etc., but was fun to write. After
5: beating the program around for a while, I managed to get
6: it down to:
7:
8: (Updated: removed unnecessary assignment to %a. Thanks merlyn)
9: perl -na0777e 'map {++$a{$_}} @F; print join("\n", (sort { $a{$b} <=> $a{$a} } keys %a)[0..9]), "\n"' <filename>
10:
11: And after all that, I didn't even get a very good grade. In reply to Word Counter by plaid
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |