This one reads STDIN, counts words (here words are things between whitespace), and prints them sorted in descending order by occurrence.
my %words;
$*IN.lines.split(/\s+/).map: { %words{$_}++ };
for %words.pairs.sort: { $^b.value <=> $^a.value } -> $pair { say $pair }
It's like longhand for
perl -lne '$x{$_}++ for split; END { print "$_\t$x{$_}" for sort { $x{$a} $x{$b} } keys %x }
Re:Sweet!
educated_foo on 2008-12-09T22:54:11
Ugh.
$x{$b} <=> $x{$a}
.