Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: History Meme, in Perl!

by kyle (Abbot)
on Apr 11, 2008 at 18:54 UTC ( [id://679816]=note: print w/replies, xml ) Need Help??


in reply to History Meme, in Perl!

Wow, the number one item in my history is perl! I guess that comes from running everything as "perl blahblah.pl". Number two is cd. And it appears I use perldoc more often than man.

Using the suggestion from rhesa,

history|perl -lane '$h{$F[1]}++;END{print"$h{$_} $_"for(sort{$h{$b}<=> +$h{$a}}keys%h)[0..9]}'

Replies are listed 'Best First'.
Re^2: History Meme, in Perl!
by jdporter (Paladin) on Apr 11, 2008 at 20:26 UTC

    Shorter:

    system q(history|awk '{a[$2]++ } END{for(i in a){print a[i] " " i}}'|s +ort -rn|head)
      bash: system: command not found

      Not only that, "perl -e 'system q(history)'" produces no output, presumably because the subshell that perl spanws for system doesn't have a history.

        bash: system: command not found

        What in the world gave you the idea this was supposed to be a bash script? Aren't we golfing Perl?

        "perl -e 'system q(history)'" produces no output...

        Yowch. Now that is a problem. :-(

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://679816]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (5)
As of 2024-03-28 07:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found