Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

Re^2: Favourite modules April 2003 (scripted top10 list)

by Aristotle (Chancellor)
on Apr 16, 2003 at 00:43 UTC ( #250746=note: print w/replies, xml ) Need Help??

in reply to Re: Favourite modules April 2003
in thread Favourite modules April 2003

You can certainly do alot better than that long piece of code for this task though. The last two loops can be combined:
for (sort { $module{$a} <=> $module{$b} } keys %module) { printf "%04d, %s\n", $module{$_}, $_; }
Gets you rid of the synthetic @list too. I have no idea what your if/elsif are supposed to sort out, either. And finally, instead of using <DATA>, you can use <> and just pipe the output from grep to the script. A compressed version:
/^use\s+([^\s;]+)/ && $_{$1}++ while <>; printf "%04d, $_\n", $_{$_} for sort { $_{$b} <=> $_{$a} } keys %_;
And then it's just
$ grep -hr ^use perl/ | perl

Makeshifts last the longest.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2016-10-25 14:41 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (321 votes). Check out past polls.