Perl模块的安装、卸载以及检查已安装的模块

How do I install Perl modules?

installing a new module can be as simple as typing perl -MCPAN -e 'installChocolate::Belgian'. The CPAN.pm documentation has more completeinstructions on how to use this convenient tool. If you are uncomfortable withhaving something take that much control over your software installation, or itotherwise doesn't work for you, the  perlmodinstall documentation covers moduleinstallation for UNIX, Windows and Macintosh in more familiar terms.

Finally, if you're using ActivePerl on Windows, the  PPM (Perl Package Manager) has much of the samefunctionality as CPAN.pm.


How do I remove installed Perl modules?

By using the  ExtUtils::Installed and  ExtUtils::Packlist modules that come with Perl asin the example below. There is also a more elaborate example in theExtUtils::Packlist man page.

#!/usr/local/bin/perl -w
use ExtUtils::Packlist;
use ExtUtils::Installed;
$ARGV[0] or die "Usage: $0Module::Name\n";
my $mod = $ARGV[0];
my $inst =ExtUtils::Installed->new();
     foreachmy $item (sort($inst->files($mod))) {
             print "removing $item\n";
             unlink $item;
          }
      my$packfile = $inst->packlist($mod)->packlist_file();
          print "removing $packfile\n";
          unlink $packfile;

How do I find out what modules are already installed on my system?

  • perldoc perllocal

Each time a module is installed on your system, itappends information like the following to a file called perllocal.pod which can be found in /usr/local/lib/perl5/version number/architecture/ or something akin to that. The path for your specificinstallation is in your @INC which you can divine with perl -V.

=head2 Wed May 12 13:42:53 1999: C<Module>L<Data::Dumper>

=over 4

=item *

C<installed into: /usr/local/lib/perl5/5.00503>

=item *

C<LINKTYPE: dynamic>

=item *

C<VERSION: 2.101>

=item *

C<EXE_FILES: >

=back

Each entry includes the Module name, date and time it wasinstalled, where it was installed, linktype [ static or dynamic ], version andexecutables, if any, included with the module.

  • Use the ExtUtils::Installed module

ExtUtils::Installed provides a standard way tofind out what core and module files have been installed. It uses theinformation stored in .packlist files created during installation to providethis information. In addition it provides facilities to classify the installedfiles and to extract directory information from the .packlist files.

#!/usr/local/bin/perl
use ExtUtils::Installed;
my $instmod =ExtUtils::Installed->new();
foreach my $module($instmod->modules()) {
my $version =$instmod->version($module) || "???";
       print "$module -- $version\n";
}

produces the following list of modules and their version

Apache::DBI -- 0.87

Apache::DBILogConfig -- 0.01

Apache::DBILogger -- 0.93

AppConfig -- 1.52

Archive::Tar -- 0.22

BerkeleyDB -- 0.06

CGI -- 2.74

CPAN -- 1.59

CPAN::WAIT -- 0.27

Catalog -- 1.00

Compress::Zlib -- 1.11

Config::IniFiles -- 2.14

Convert::BER -- 1.26

Coy -- ???

Crypt::Rot13 -- 0.04

Crypt::SSLeay -- 0.16

DBI -- 1.14

[.....]

 转载自如流,新一代智能工作平台

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值