Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Perl modules lister

by Anonymous Monk
on Apr 20, 2005 at 18:52 UTC ( #449718=perlquestion: print w/ replies, xml ) Need Help??
Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

could someone show script that list all perl modules installed?(without some special modules)

Comment on Perl modules lister
Replies are listed 'Best First'.
Re: Perl modules lister
by cog (Parson) on Apr 20, 2005 at 18:53 UTC
Re: Perl modules lister
by revdiablo (Prior) on Apr 20, 2005 at 19:01 UTC
    perl -MFile::Find -le 'for (@INC) { find(sub { print $File::Find::name if /pm$/ }, $_) }'

    Update: here's one that cleans up the output to resemble the module names, rather than the .pm filenames:

    perl -MFile::Find -le ' for $inc (@INC) { find(sub { return unless /pm$/; ($module = $File::Find::name) =~ s!^$inc/!!; $module =~ s!/!::!g; $module =~ s/.pm$//; print $module }, $inc) }'
Re: Perl modules lister
by naChoZ (Curate) on Apr 21, 2005 at 01:56 UTC

    Also worth a look: pmdesc2 - lists modules with description

    There's also a reply I posted on how to make a locate database out of it.

    "This alcoholism thing, I think it's just clever propaganda produced by people who want you to buy more bottled water." -- pedestrianwolf

Re: Perl modules lister
by bofh_of_oz (Hermit) on Apr 20, 2005 at 19:53 UTC
    I believe this should do what you need (run from shell):
    perl -e 'foreach $a (@INC){next if ($a eq ".");if(-d $a){@m = `nice fi +nd $a -name *.pm`;} map {s/^$a\/?(.*)\.pm$/$1/;s/\//::/g; push (@n,$_ +) if ($_!~/\.|-/);} @m; print @n;}'
    Also, you can try this link - looks like they print the resulting list of installed modules to a web page.

      File::Find has been part of the standard perl distribution since 5.00307, which was released in Oct 1996. I think it's safe to assume most perl installations have it available, and you can avoid rolling your own path traversal code. :-)

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (3)
As of 2015-12-02 05:06 GMT
Find Nodes?
    Voting Booth?

    My keyboard shows this many letters:

    Results (34 votes), past polls