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

Listing all of the perl modules installed

by Anonymous Monk
on Oct 28, 2010 at 20:28 UTC ( [id://868141]=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Dear all

Please can you tell me how you find all of the perl modules installed under Linux. I have found this command which does list some perl modules in /usr/lib/perl5 and /usr/share/perl5 but I get the error 'Can't stat /usr/local/lib/site_perl: No such file or directory at -e line 1'
My path is /usr/local/lib/perl not site_perl

perl -MFile::Find=find -MFile::Spec::Functions -Tlwe \ 'find { wanted => sub { print canonpath $_ if /\.pm\z/ }, no_chdir => +1 }, @INC'
It would also be great to know how to modify that command to show files that match a particular text string

YOur help is much appreciated

Replies are listed 'Best First'.
Re: Listing all of the perl modules installed
by toolic (Bishop) on Oct 28, 2010 at 23:36 UTC
Re: Listing all of the perl modules installed
by Tux (Canon) on Oct 29, 2010 at 06:14 UTC

    I bet searching here on monks would have given you a few examples of how monks do this. There is a plethora of scripts available by now as there are many ways to answer the question.

    I also wrote a script myself, but with a few additions to make it easier to find module not (yet) installed, so that I don't have to dig on CPAN when I'm looking for a module that does XML/XPM/CSV/mysql/...

    Note that my script works based on the list of modules available as seen by CPAN, so it will not find modules that were manually copied into the perl tree.

    $ modlist -? usage: modlist [ -a AUT ] [ -r ] [ -i ] [ -nc ] [ <pattern> ] -a | --author=AUTHOR_ID Only modules from author -r | --registered Only registered modules -i | --installed Only installed modules -n | --new Only new modules -c | --csv Output module and version as CSV <pattern> Only modules that match pattern $ modlist -i xpm Module name Description + Version Bundle::Image::Info::XPM + 0.01 Image::Info::XPM + 1.07 Image::Xpm + 1.12 Tk::XPMs + 1.11 $ modlist -r peek Module name Description + Version Apache::Peek Devel::Peek for mod_perl Data::Peek A collection of low-level debug facilities + 0.31 Devel::Peek Peek at internal representation of Perl data + 1.04 Core since 5.006 1.00_01 in 5.010001 + 1.04 POE::API::Peek Peek into the internals of a running POE env $

    It also does colorizing (when available), shows if it is a CORE module (using Module::Corelist), since when and what version in core,


    Enjoy, Have FUN! H.Merijn
      Yeah, I did the search as suggested, and found it lacking. All I want is a way to use Module::Corelist to list the modules that are installed with perl on my box. Pretty simple, I'd say, but nothing I've found here on this site, seems to just do that. I read the doc from CPAN on Module::Corelist, and came up empty there also. Is this really that tough of a request? Just a simple script that uses Module::Corelist to list the installed modules. That's it.
        Revised comment: Thank you, I did finally find one. Not simple by any means, but I did find one.
Re: Listing all of the perl modules installed
by bingos (Vicar) on Oct 28, 2010 at 21:21 UTC

    I have a script that finds and lists all the installed modules on a system

    A slight variation on that theme for listing all the distributions that are installed

Re: Listing all of the perl modules installed
by kejohm (Hermit) on Oct 29, 2010 at 03:09 UTC

    You could try using the ExtUtils::Installed and Module::CoreList modules. Here is an example that finds all modules and displays the version numbers of each:

    #!perl use strict; use warnings; use feature qw(:5.12); use ExtUtils::Installed; use Module::CoreList; use Module::Info; my $inst = ExtUtils::Installed->new(); my $count = 0; my %modules; foreach ( $inst->modules() ) { next if m/^[[:lower:]]/; # skip pragmas next if $_ eq 'Perl'; # core modules aren't present in this +list, # instead coming under the name Perl my $version = $inst->version($_); $version = $version->stringify if ref $version; # version may be r +eturned as # a version object $modules{$_} = { name => $_, version => $version }; $count++; } foreach ( Module::CoreList->find_modules() ) { next if m/^[[:lower:]]/; # skip pragmas my $module = Module::Info->new_from_module($_) or next; $modules{$_} = { name => $_, version => $module->version // q(???) + }; $count++; } foreach ( sort keys %modules ) { say "$_ v$modules{$_}{version}"; } say "\nModules: $count"; __END__

    Update: Links fixed.

Re: Listing all of the perl modules installed
by Khen1950fx (Canon) on Oct 28, 2010 at 22:34 UTC
    Here's an easy way:

    pminst - shows all installed modules
    pminst -l - shows all installed modules with full path

    To match a particular text string, I'll use 'sample':

    pminst '(?i)sample'

      unfortunately, pminst is part of pmtools, which isn't part of the core. And wouldn't work anyway where I work.
Re: Listing all of the perl modules installed (autobundle)
by Anonymous Monk on Feb 01, 2013 at 14:39 UTC
Re: Listing all of the perl modules installed
by PerlPundit (Initiate) on Aug 25, 2015 at 10:44 UTC
    The following command can be helpful in finding the installed perl modules : instmodsh It will give some options - Press l and enter This will list down all the installed modules. Hope it Helps!!!!!!!!!!!!!!! :-)
        Thanks for the info Anon: I haven't tried it on debian yet. What about lsmod ?- I think this can be used in debian.
      Yup, that did exactly what I needed. Thanks
Re: Listing all of the perl modules installed
by Anonymous Monk on Feb 01, 2013 at 03:20 UTC

    To see all the modules you've installed using something like cpanm, do: perldoc perllocal

    To see a list of system packages on a Debian-based system (that is, ones installed via apt), do:

    dpkg -l | grep 'lib.*\?-perl'

      Also, corelist can show you all core modules installed for any version of Perl 5 you care to ask about, for example:

      corelist -v 5.16.2

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://868141]
Approved by Corion
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (4)
As of 2024-04-19 13:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found