ExtUtils::Installed
1.1、ExtUtils::Installed简介
是什么 ?:Inventory management of installed Perl modules.
开发语言:Perl
metacpan:https://metacpan.org/pod/ExtUtils::Installed
1.2、通过包管理器安装ExtUtils::Installed
操作系统包管理器安装命令
Allcpancpan -i ExtUtils::Installed
Allcpanmcpanm ExtUtils::Installed
CentOSyumsudo yum install -y perl-ExtUtils-Install
dnfsudo dnf install -y perl-ExtUtils-Install
openSUSEzyppersudo zypper install -y perl-ExtUtils-Install
1.3、ExtUtils::Installed API
1.3.1、$installed = ExtUtils::Installed -> new()

创建ExtUtils::Installed实例。

示例:

use ExtUtils::Installed;
my $installed = ExtUtils::Installed -> new();
1.3.2、@moduleNames = $installed -> modules()

列出所有已安装模块的名字。

示例:

my @moduleNames = $installed -> modules();
foreach (@moduleNames) {
    print "$_\n";
}
1.3.3、$version = $installed -> version($moduleName)

查看指定模块的版本。

示例1:

my $version = $installed -> version("ExtUtils::Installed");

示例2:

my @moduleNames = $installed -> modules();
foreach (@moduleNames) {
    my $version = $installed -> version($_) || "???";
    printf("%-22s -Version- %-22s\n", $_, $version);
}
1.3.4、@files = $installed -> files($moduleName)

查看指定模块的文件。

示例1:

my @files = $installed -> files("ExtUtils::Installed");
foreach (@files) {
    print "$_\n";
}

示例2:

my @moduleNames = $installed -> modules();
foreach (@moduleNames) {
    my @files = $installed -> files($_);
    foreach (@files) {
        print "$_\n";
    }
}
1.3.5、@dirs = $installed -> directories($moduleName)

查看指定模块的目录。

示例1:

my @dirs = $installed -> directories("ExtUtils::Installed");
foreach (@dirs) {
    print "$_\n";
}

示例2:

my @moduleNames = $installed -> modules();
foreach (@moduleNames) {
    my @dirs = $installed -> directories($_);
    foreach (@dirs) {
        print "$_\n";
    }
}
1.3.6、@dirs = $installed -> directory_tree($moduleName)

查看指定模块的目录树。

示例1:

my @dirs = $installed -> directory_tree("ExtUtils::Installed");
foreach (@dirs) {
    print "$_\n";
}

示例2:

my @moduleNames = $installed -> modules();
foreach (@moduleNames) {
    my @dirs = $installed -> directory_tree($_);
    foreach (@dirs) {
        print "$_\n";
    }
}
1.3.7、@missingFiles = $installed -> validate($moduleName)

查看指定模块的文件是否有遗失。

示例:

my @missingFiles = $installed -> validate("ExtUtils::Installed");
my $missingFileCount = @missingFiles;
if ($missingFileCount == 0) {
    print "OK\n";
} else {
    print "KO\n";
}