问题描述
在所有 @INC
目录中进行递归操作时,将为您提供"Perl知道的"模块,找到包含这些模块的 all 的最干净方法是什么是在(Linux)系统上构建的?
While recursing through all of the @INC
directories will give you the modules that "Perl knows about", what's the cleanest way to find all of the modules that have been built on a (Linux) system?
推荐答案
这是Perl常见问题解答,即如何查找系统上安装了哪些模块?,您可以找到以下答案:通过 perldoc -q已安装
或 perldoc perlfaq3
来查询此问题,然后搜索已安装".
This is a Perl FAQ, i.e. How do I find which modules are installed on my system?, you can find the answer for this question by perldoc -q installed
or perldoc perlfaq3
and then search for 'installed'.
以下是在"perlfaq3.pod"中对该问题的答案的摘要,以及根据我对它的测试得出的关于答案本身的一些注释:
Here is a summary of the answer in 'perlfaq3.pod' to this question and some notes about the answer itself according to my test of it:
-
在命令行上使用
cpan
:
cpan -l
注意:您可能需要安装额外的软件包才能使用此命令,例如,您需要在Fedora 19中安装"perl-CPAN".
Note: You may need to install extra package to use this command, for example, you need to install 'perl-CPAN' in Fedora 19.
在Perl脚本中使用 ExtUtils :: Installed
:
use ExtUtils::Installed
in a Perl script:
use ExtUtils::Installed;
my $inst = ExtUtils::Installed->new();
my @modules = $inst->modules();
注意:这可能无法列出您的软件包管理系统安装的所有模块.
Note: this may not be able to list all the modules installed by your package management system.
使用 File :: Find :: Rule
查找所有模块文件:
use File::Find::Rule
to find all the module files:
use File::Find::Rule;
my @files = File::Find::Rule->
extras({follow => 1})->
file()->
name( '*.pm' )->
in( @INC )
;
注意:这不是标准模块,您可能需要先安装它.
Note: this is not a standard module, you may need to install it first.
使用 File :: Find
查找所有模块文件:
use File::Find
to find all the module files:
use File::Find;
my @files;
find(
{
wanted => sub {
push @files, $File::Find::fullname
if -f $File::Find::fullname && /\.pm$/
},
follow => 1,
follow_skip => 2,
},
@INC
);
print join "\n", @files;
如果您知道模块名称,并且只想检查系统中是否存在模块名称,则可以使用以下命令:
if you know the module name and just want to check whether it exists in your system, you can use the following commands:
perldoc Module::Name
或
perl -MModule::Name -e1
以下链接也可能有帮助:
The following links may also be helpful:
这篇关于获取全套已安装的Perl模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!