如何找到已安装的 Perl 模块的版本? [英] How can I find the version of an installed Perl module?

查看:31
本文介绍了如何找到已安装的 Perl 模块的版本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何找到已安装的 Perl 模块的版本?

这是在底部的答案中,但我认为住在这里很重要.根据这些建议,我在 .bashrc

中创建了一个函数

function perlmodver {perl -M$1 -e '打印版本".$ARGV[0]-> 版本."的 " .$ARGV[0] ." 已安装.
"' $1}

解决方案

为什么要尝试获取模块的版本?您是否需要在程序中使用它,您是否只需要将数字传递给另一个操作,或者您只是想找出您拥有的东西?

我将它内置到带有 -D 开关的 cpan(perl 附带)中,这样您就可以看到您安装的版本和当前版本CPAN:

<前>$ cpan -D 文本::CSV_XS文本::CSV_XS-------------------------------------------------------------------------Text::CSV 的快速 8 位清洁版本H/HM/HMBRAND/Text-CSV_XS-0.54.tgz/usr/local/lib/perl5/site_perl/5.8.8/darwin-2level/Text/CSV_XS.pm已安装:0.32CPAN:0.54 不是最新的H.Merijn 品牌 (HMBRAND)h.m.brand@xs4all.nl

如果您想查看所有过时的模块,请使用 -O(大写 O)开关:

<前>$ cpan -O模块名称本地CPAN-------------------------------------------------------------------------阿帕奇::数据库 0.1300 0.1400Apache::SOAP 0.0000 0.7100阿帕奇::会话 1.8300 1.8700Apache::SizeLimit 0.0300 0.9100Apache::XMLRPC::Lite 0.0000 0.7100... 等等

如果您想查看已安装的所有模块,请尝试使用 -a 开关来创建自动捆绑包.

How do you find the version of an installed Perl module?

This is in an answer down at the bottom, but I figure it important enough to live up here. With these suggestions, I create a function in my .bashrc

function perlmodver {
    perl -M$1 -e 'print "Version " . $ARGV[0]->VERSION . " of " . $ARGV[0] . 
    " is installed.
"' $1
}

解决方案

Why are you trying to get the version of the module? Do you need this from within a program, do you just need the number to pass to another operation, or are you just trying to find out what you have?

I have this built into the cpan (which comes with perl) with the -D switch so you can see the version that you have installed and the current version on CPAN:

$ cpan -D Text::CSV_XS

Text::CSV_XS
-------------------------------------------------------------------------
        Fast 8bit clean version of Text::CSV
        H/HM/HMBRAND/Text-CSV_XS-0.54.tgz
        /usr/local/lib/perl5/site_perl/5.8.8/darwin-2level/Text/CSV_XS.pm
        Installed: 0.32
        CPAN:      0.54  Not up to date
        H.Merijn Brand (HMBRAND)
        h.m.brand@xs4all.nl

If you want to see all of the out-of-date modules, use the -O (capital O) switch:

$ cpan -O
Module Name                                Local    CPAN
-------------------------------------------------------------------------
Apache::DB                                0.1300  0.1400
Apache::SOAP                              0.0000  0.7100
Apache::Session                           1.8300  1.8700
Apache::SizeLimit                         0.0300  0.9100
Apache::XMLRPC::Lite                      0.0000  0.7100
... and so on

If you want to see this for all modules you have installed, try the -a switch to create an autobundle.

这篇关于如何找到已安装的 Perl 模块的版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆