加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

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

发布时间:2020-12-15 21:07:03 所属栏目:大数据 来源:网络整理
导读: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 uncomforta

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::Namen";

my $mod = $ARGV[0];

my $inst =ExtUtils::Installed->new();

???? foreachmy $item (sort($inst->files($mod))) {

?????????????print "removing $itemn";

?????????????unlink $item;

??????????}

????? my$packfile = $inst->packlist($mod)->packlist_file();

??????????print "removing $packfilen";

??????????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 -- $versionn";

}

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

[.....]

?转载自http://hi.baidu.com/tkocn/blog/item/98bdeb07757cb8ce7a89477b.html

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读