How do I get a list of installed CPAN modules?

后端 未结 29 2084
盖世英雄少女心
盖世英雄少女心 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:49

    This is what I do: perl -M{cpan_module}
    If you don't receive any errors there is a good chance that the module is installed.

    0 讨论(0)
  • 2020-12-04 07:50
    cd /the/lib/dir/of/your/perl/installation
    perldoc $(find . -name perllocal.pod)
    

    Windows users just do a Windows Explorer search to find it.

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

    You can try ExtUtils-Installed, but that only looks in .packlists, so it may miss modules that people moved things into @INC by hand.

    I wrote App-Module-Lister for a friend who wanted to do this as a CGI script on a non-shell web hosting account. You simple take the module file and upload it as a filename that your server will treat as a CGI script. It has no dependencies outside of the Standard Library. Use it as is or steal the code.

    It outputs a list of the modules and their versions:

    Tie::Cycle      1.15
    Tie::IxHash     1.21
    Tie::Toggle     1.07
    Tie::ToObject   0.03
    Time::CTime     99.062201
    Time::DaysInMonth       99.1117
    Time::Epoch     0.02
    Time::Fuzzy     0.34
    Time::JulianDay 2003.1125
    Time::ParseDate 2006.0814
    Time::Timezone  2006.0814
    

    I've been meaning to add this as a feature to the cpan tool, so I'll do that too. [Time passes] And, now I have a -l switch in cpan. I have a few other things to do with it before I make a release, but it's in github. If you don't want to wait for that, you could just try the -a switch to create an autobundle, although that puts some Pod around the list.

    Good luck;

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

    As you enter your Perl script you have all the installed modules as .pm files below the folders in @INC so a small bash script will do the job for you:

    #!/bin/bash
    
    echo -e -n "Content-type: text/plain\n\n"
    
    inc=`perl -e '$, = "\n"; print @INC;'`
    
    for d in $inc
    do
       find $d -name '*.pm'
    done
    
    0 讨论(0)
  • 2020-12-04 07:54

    On Linux/Unix I use this simple command:

    perl -e 'print qx/find $_ -name "*.pm"/ foreach ( @INC );' 
    

    It scans all folder in @INC and looks for any *.pm file.

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

    Try the following command

    instmodsh

    0 讨论(0)
提交回复
热议问题