http://www.perlmonks.org?node_id=449718

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)

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) }'
    A reply falls below the community's threshold of quality. You may see it by logging in.
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.
    http://webnet77.com/scripts/list-modules/

      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. :-)