Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

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 foo.pl

Makeshifts last the longest.


Comment on Re^2: Favourite modules April 2003 (scripted top10 list)
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (10)
As of 2015-03-31 11:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When putting a smiley right before a closing parenthesis, do you:









    Results (662 votes), past polls