Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Favourite modules April 2003

by hsmyers (Canon)
on Apr 15, 2003 at 21:57 UTC ( #250696=note: print w/ replies, xml ) Need Help??


in reply to Favourite modules April 2003

Here, including my own stuff are my top 20 according to useage---

  • 0010, Carp::Assert
  • 0011, XML::Twig
  • 0012, Chess::PGN::Moves
  • 0013, Carp
  • 0013, Wild
  • 0016, Chess::PGN::Filter
  • 0016, Getopt::Std
  • 0017, Parse::RecDescent
  • 0018, File::Basename
  • 0021, DB_File
  • 0021, Pod::Usage
  • 0022, Text::Wrap
  • 0023, Getopt::Long
  • 0027, Text::DelimMatch
  • 0032, Text::CSV
  • 0039, Chess::PGN::Parse
  • 0045, Test
  • 0046, ExtUtils::MakeMaker
  • 0048, Data::Dumper
  • 0062, Chess::PGN::EPD
  • 0068, constant
  • 0223, diagnostics
  • 0223, warnings
  • 0239, strict

How do I know this? Fairly easy, go to the root of your Perl development tree on the box of your choice and append the results of 'grep -rd "^use " *.pl' to this:

#!/perl/bin/perl # # use.pl -- statistics for 'use' module name. use strict; use warnings; use diagnostics; my %module; my @list; while (<DATA>) { if (/^use\s(.*?);/) { my $what = $1; if ($what =~ /^lib/) { $module{'lib'}++; } elsif ($what =~ /^constant/) { $module{'constant'}++; } else { $module{$what}++; } } } for (keys %module) { push(@list,sprintf("%04d|%s",$module{$_},$_)); } for (sort @list) { my($howmany,$what) = split /\|/; print "$howmany, $what\n"; } __DATA__

And then run the script...

--hsm

"Never try to teach a pig to sing...it wastes your time and it annoys the pig."


Comment on Re: Favourite modules April 2003
Download Code
Re^2: Favourite modules April 2003 (scripted top10 list)
by Aristotle (Chancellor) on Apr 16, 2003 at 00:43 UTC
    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.

Re: Re: Favourite modules April 2003
by zakzebrowski (Curate) on Apr 17, 2003 at 12:21 UTC
    Does usage though == favourite module? (Thanks for the code snip it though!)

    ----
    Zak
    Pluralitas non est ponenda sine neccesitate - mysql's philosphy

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2014-09-20 03:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (152 votes), past polls