How do I get a list of installed CPAN modules?

后端 未结 29 2131
盖世英雄少女心
盖世英雄少女心 2020-12-04 07:41

Aside from trying

perldoc 

individually for any CPAN module that takes my fancy or going through the file system and loo

相关标签:
29条回答
  • 2020-12-04 07:47
    $ for M in `perldoc -t perllocal|grep Module |sed -e 's/^.*" //'`; do V=`perldoc -t perllocal|awk "/$M/{y=1;next}y" |grep VERSION |head -n 1`; printf "%30s %s\n" "$M" "$V"; done |sort
                  Class::Inspector     *   "VERSION: 1.28"
                        Crypt::CBC     *   "VERSION: 2.33"
                   Crypt::Rijndael     *   "VERSION: 1.11"
                        Data::Dump     *   "VERSION: 1.22"
                       DBD::Oracle     *   "VERSION: 1.68"
                               DBI     *   "VERSION: 1.630"
                       Digest::SHA     *   "VERSION: 5.92"
               ExtUtils::MakeMaker     *   "VERSION: 6.84"
                           install     *   "VERSION: 6.84"
                   IO::SessionData     *   "VERSION: 1.03"
                   IO::Socket::SSL     *   "VERSION: 2.016"
                              JSON     *   "VERSION: 2.90"
                      MIME::Base64     *   "VERSION: 3.14"
                      MIME::Base64     *   "VERSION: 3.14"
                       Mozilla::CA     *   "VERSION: 20141217"
                       Net::SSLeay     *   "VERSION: 1.68"
                            parent     *   "VERSION: 0.228"
                      REST::Client     *   "VERSION: 271"
                        SOAP::Lite     *   "VERSION: 1.08"
                      Task::Weaken     *   "VERSION: 1.04"
                     Term::ReadKey     *   "VERSION: 2.31"
                    Test::Manifest     *   "VERSION: 1.23"
                      Test::Simple     *   "VERSION: 1.001002"
                      Text::CSV_XS     *   "VERSION: 1.16"
                         Try::Tiny     *   "VERSION: 0.22"
                       XML::LibXML     *   "VERSION: 2.0108"
             XML::NamespaceSupport     *   "VERSION: 1.11"
                    XML::SAX::Base     *   "VERSION: 1.08"
    
    0 讨论(0)
  • 2020-12-04 07:48

    This is answered in the Perl FAQ, the answer which can be quickly found with perldoc -q installed. In short, it comes down to using ExtUtils::Installed or using File::Find, variants of both of which have been covered previously in this thread.

    You can also find the FAQ entry "How do I find which modules are installed on my system?" in perlfaq3. You can see a list of all FAQ answers by looking in perlfaq

    0 讨论(0)
  • 2020-12-04 07:48

    I wrote a perl script just yesterday to do exactly this. The script returns the list of perl modules installed in @INC using the '::' as the separator. Call the script using -

    perl perlmod.pl
    

    OR

    perl perlmod.pl <module name> #Case-insensitive(eg. perl perlmod.pl ftp)
    

    As of now the script skips the current directory('.') since I was having problems with recursing soft-links but you can include it by changing the grep function in line 17 from

      grep { $_ !~ '^\.$' } @INC
    

    to just,

    @INC
    

    The script can be found here.

    0 讨论(0)
  • 2020-12-04 07:49
    perldoc perllocal
    

    Edit: There's a (little) more info about it in the CPAN FAQ

    0 讨论(0)
  • 2020-12-04 07:49

    perldoc -q installed

    claims that cpan -l will do the trick, however it's not working for me. The other option:

    cpan -a

    does spit out a nice list of installed packages and has the nice side effect of writing them to a file.

    0 讨论(0)
  • 2020-12-04 07:49

    Here's a script by @JamesThomasMoon1979 rewritten as a one-liner

    perl -MExtUtils::Installed -e '$i=ExtUtils::Installed->new(); 
          print "$_ ".$i->version($_)."\n" for $i->modules();'
    
    0 讨论(0)
提交回复
热议问题