简体   繁体   English

如何升级从 CPAN 安装的 perl 模块?

[英]How to upgrade perl modules that install from CPAN?

在cpan shell中,只有/regexp/或所有模块都可以升级,如果我想升级只有CPAN安装的模块,怎么办?

I suggest you using cpanm "family" script for perl modules management.我建议您使用 cpanm “family” 脚本进行 perl 模块管理。

Install cpanm安装cpanm

  • skip this, if you already have it跳过这个,如果你已经有了它
  • curl -L http://cpanmin.us | perl - --sudo App::cpanminus
  • if you're on freebsd you can use instead curl the command fetch (see: man fetch)如果你在 freebsd 上,你可以使用 curl 命令获取(参见:man fetch)

Upgrade cpanm升级cpanm

  • skip this, if you installed it right now跳过这个,如果你现在安装它
  • cpanm --self-upgrade --sudo

Install cpan-outdated安装cpan-outdated

  • cpanm App::cpanoutdated
  • The cpan-outdated command do the same as CPAN (r), but IMO better to use from shell cpan-outdated 命令的作用与 CPAN (r) 相同,但 IMO 更适合从 shell 使用

For example, only my notebook gives the result like:例如,只有我的笔记本给出如下结果:

marvin:~ jomo$ cpan-outdated
S/SM/SMUELLER/Attribute-Handlers-0.93.tar.gz
D/DR/DROLSKY/Class-Load-0.20.tar.gz
D/DR/DROLSKY/DateTime-TimeZone-1.47.tar.gz
... etc

Run cpan-outdated & upgrade modules运行 cpan-outdated & upgrade 模块

  • cpan-outdated -p | cpanm

Changes变化

If you want see what is changed (Change-log), you can try install cpan-listchanges如果您想查看更改的内容(更改日志),您可以尝试安装cpan-listchanges

  • cpanm App::cpanlistchanges
  • and use it like: cpan-listchanges Plack - too see what's changed in Plack between your local and the latest on CPAN并像这样使用它: cpan-listchanges Plack - 也看看你的本地和 CPAN 上的最新版本之间在 Plack 中发生了什么变化
# cpan
cpan> h

Display Information                                                (ver 1.9800)
 command  argument          description
 a,b,d,m  WORD or /REGEXP/  about authors, bundles, distributions, modules
 i        WORD or /REGEXP/  about any of the above
 ls       AUTHOR or GLOB    about files in the author's directory
    (with WORD being a module, bundle or author name or a distribution
    name of the form AUTHOR/DISTRIBUTION)

Download, Test, Make, Install...
 get      download                     clean    make clean
 make     make (implies get)           look     open subshell in dist directory
 test     make test (implies make)     readme   display these README files
 install  make install (implies test)  perldoc  display POD documentation

Upgrade
 r        WORDs or /REGEXP/ or NONE    report updates for some/matching/all modules
 upgrade  WORDs or /REGEXP/ or NONE    upgrade some/matching/all modules

Pragmas
 force  CMD    try hard to do command  fforce CMD    try harder
 notest CMD    skip testing

Other
 h,?           display this menu       ! perl-code   eval a perl command
 o conf [opt]  set and query options   q             quit the cpan shell
 reload cpan   load CPAN.pm again      reload index  load newer indices
 autobundle    Snapshot                recent        latest CPAN uploads

Running just the below command will do what you ask.仅运行以下命令即可满足您的要求。

cpan> upgrade
$ cpan Module

and

cpan> install Module 

will upgrade if a newer version is available, and do nothing if you already have the latest version.如果有更新的版本可用,将升级,如果您已经有最新版本,则不执行任何操作。

You should first log into cpan.您应该首先登录 cpan。 Then, once at the prompt type:然后,一旦在提示符下键入:

r  [enter]

That will print out a list of upgradable modules that are installed.这将打印出已安装的可升级模块列表。 After you have that list to work off of you can use the following:在您拥有该列表后,您可以使用以下内容:

cpan upgrade <MODULE NAME>

Simply replace with the name of the module to upgrade.只需替换为要升级的模块的名称。

Regards,问候,

Jeff杰夫

重新安装 perl 包将使用自动升级
cpanm --reinstall <Module_Name>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM