Created
December 6, 2016 16:09
-
-
Save takdavid/55eea5d306ba7ce3cc245a8ac954f79a to your computer and use it in GitHub Desktop.
Word count
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
my @w; | |
while (<STDIN>) { chomp; while (split /[^-\w]+/) { push @w, lc $_; } } | |
my $c = {}; | |
while (@w) { $c->{$_} += 1; } | |
my @k = reverse sort { $c->{$a} <=> $c{$b} } keys %{$c}; | |
while (@k) { print $c->{$k}, $k, "\n"; } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment