Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Listing all installed modules

by kvale (Monsignor)
on Feb 10, 2004 at 19:48 UTC ( #328005=perlquestion: print w/ replies, xml ) Need Help??
kvale has asked for the wisdom of the Perl Monks concerning the following question:

I want a list of installed Perl modules on my system. From perlfaq3, I tried the following code:
#!/usr/bin/perl -w use strict; use ExtUtils::Installed; my ($inst) = ExtUtils::Installed->new(); my (@modules) = $inst->modules(); foreach my $mod (@modules) { print "$_\n"; }
which results in the useless output
.packlist .packlist .packlist ... .packlist .packlist .packlist
I checked out the ExtUtils::Installed manpage and the program seems consistent with the recommended usage.The modules list is supposed to be generated from the set of .packlist, so there is a parsing step missing. What am I (and possibly the faq) doing wrong? This is a perl 5.8.0, Mandrake 9.1 system.

-Mark

Comment on Listing all installed modules
Select or Download Code
Re: Listing all installed modules
by AcidHawk (Vicar) on Feb 10, 2004 at 20:13 UTC
    this node has a perl one liner to show installed modules.

    It goes like this

    $ perl -MExtUtils::Installed -e'my $inst = ExtUtils::Installed->new(); + print $_, $/ for $inst->modules'

    More here and here

    To get yours to work change print "$_\n"; to print "$mod\n";

    You are wanting to print $mod as apposed to $_

    -----
    Of all the things I've lost in my life, its my mind I miss the most.
Re: Listing all installed modules
by bassplayer (Monsignor) on Feb 10, 2004 at 20:16 UTC
    This is a commonly asked question. Did you search? :-)

    Update: AcidHawk's got your particular solution above.

    bassplayer

Re: Listing all installed modules
by scottj (Monk) on Feb 10, 2004 at 21:23 UTC
    Not exactly what you're looking for, but perldoc perllocal will show everything that you've installed with CPAN.

    I've also seen a one-liner which does something more along the lines of what you are asking about, although it doesn't seem to return a complete list:

    perl -MExtUtils::Installed -e'my $inst = ExtUtils::Installed->new(); print $_, $/ for $inst->modules'

    Update: Actually, the second option that I gave does give a complete output. I forgot that ExtUtils::Installed uses "Perl" to represent the core modules. So you're still not technically getting a complete listing of all modules, but according to the method ExtUtils::Installed is using, the listing is complete.

    Because of the method used by ExtUtils::Installed to represent the core, you are basically getting the same from both of the above options. The difference is that the second returns a nice, clean list, while the first is intended to be in a human-readable format.
      beware of evil software that deletes perllocal (stupid Makefile.PL for Everything-base distribution)
Re: Listing all installed modules
by duff (Vicar) on Feb 10, 2004 at 22:51 UTC

    Alternatively, you could use the pminst program provided with pmtools. Oddly enough, this and the other methods given are listed in the CPAN faq

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (12)
As of 2014-07-11 17:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (232 votes), past polls