History meme, in Perl!

11.04.2008 13:19

posted by: Benjamin Smith

Posted Under: , , ,

So I submitted a post to perlmonks RE: all the 'history meme' brouhaha. I provided two one liners in Perl (Below) and asked for people to improve/shorten/spice up the 'history meme' via Perl. We'll see how that goes :).

So, here's what I gave them to start with:

history | perl -le 'while($l = <>) 
{$n=${[split(/s+/,$l)]}[2];$h{$n}++;} $i=0;foreach $k 
(reverse sort {$h{$a}<=>$h{$b}} keys %h) {last if $i > 9; print "$h{$k} $k"; $i++;}'
history | perl -le 'while($l = <>) ;
{$n=${[split(/s+/,$l)]}[2];$h{$n}++;} $i=0;@a=reverse 
sort {$h{$a}<=>$h{$b}} keys %h; print "$h{$a[$_]} $a[$_]" for (0..9)'
0 comments | 0 pingbacks
Add post to: Delicious Reddit Slashdot Digg Technorati Google
Comment

Comments

No comments for this post

Comment form for «History meme, in Perl!»

Required. 30 chars of fewer.

Required.

captcha image Please, enter symbols, which you see on the image