Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

Re^2: Golf: Count unique words

by Fletch (Chancellor)
on Nov 30, 2004 at 15:24 UTC ( #411209=note: print w/replies, xml ) Need Help??

in reply to Re: Golf: Count unique words
in thread Golf: Count unique words

73 (70 + 3 for the switches). The \b's are pretty much unnecessary and using $& means you don't need parens.

#!/usr/bin/perl -nl END{print map("$_ ($w{$_})\n",sort keys%w),$t}s/\w+/$w{$&}++;$t++/eg;

Replies are listed 'Best First'.
Re^3: Golf: Count unique words
by eyepopslikeamosquito (Chancellor) on Dec 01, 2004 at 06:36 UTC

    Sh?aving seven strokes:

    #!/usr/bin/perl -lp ++$t,++$w{$_}for/\w+/g}for(map("$_ ($w{$_})",sort keys%w),$t){

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://411209]
[Discipulus]: which of 43 significance of NN?
[Discipulus]: NN?
[beech]: nobliest nodes
[Discipulus]: ah no newest nodes! ask something
[beech]: why is my butt itchy
Discipulus many countries without bidet.. is a big problem!
[beech]: who told you i call my butt france?

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (6)
As of 2016-12-09 09:44 GMT
Find Nodes?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:

    Results (150 votes). Check out past polls.