简体   繁体   English

如何在使用 perlbrew 时安装 CPAN 模块?

[英]How do I install CPAN modules while using perlbrew?

I have started using perlbrew and installed perl-5.12.2.我已经开始使用perlbrew并安装了 perl-5.12.2。

I understand I need to re-install my CPAN modules, so I switched to my new Perl version ( perlbrew switch perl-5.12.2 and hash -r ), verified the switch was successful ( perl -v ) then tried installing some module ( File::Copy::Recursive using cpan . However, cpan says `File::Copy::Recursive is up to date (0.38).我知道我需要重新安装我的 CPAN 模块,所以我切换到我的新 Perl 版本( perlbrew switch perl-5.12.2hash -r ),验证切换成功( perl -v )然后尝试安装一些模块( File::Copy::Recursive使用cpan 。但是, cpan说 `File::Copy::Recursive 是最新的(0.38)。

When I start a Perl script using this module, it shouts Can't locate File/Copy/Recursive.pm in @INC ... (showing many perl-5.12.2 locations).当我使用此模块启动 Perl 脚本时,它会喊出Can't locate File/Copy/Recursive.pm in @INC ... (显示许多perl-5.12.2位置)。 When I switch back to my 'normal' Perl ( perlbrew off ) the script runs fine.当我切换回我的“正常” Perl ( perlbrew off ) 时,脚本运行良好。

Any suggestions?有什么建议么? Perhaps CPAN does not work well with perlbrew ?也许 CPAN 不适用于perlbrew

After installing perlbrew you could install cpanm through this command:安装 perlbrew 后,您可以通过以下命令安装 cpanm:

perlbrew install-cpanm

Otherwise you will need to install cpanm manually each time you switch your Perl version on perlbrew.否则,每次在 perlbrew 上切换 Perl 版本时,都需要手动安装 cpanm。 With this command just once.只需使用此命令一次。

Once installed you can then use cpanm to install the missing module:安装后,您可以使用cpanm安装缺少的模块:

cpanm File::Copy::Recursive

Everything should be working fine with "cpan" as well as "cpanm", that is: when switching perl with perlbrew, cpan sees the installed modules of the version you use.使用“cpan”和“cpanm”应该一切正常,也就是说:当使用 perlbrew 切换 perl 时,cpan 会看到您使用的版本的已安装模块。

While it's true that cpanm is the recommended tool to use with perlbrew, cpan allows for test reporting so that is what I always use.虽然 cpanm 确实是与 perlbrew 一起使用的推荐工具,但 cpan 允许测试报告,所以这是我一直使用的。

How do I install CPAN modules while using perlbrew?如何在使用 perlbrew 时安装 CPAN 模块?

That's how:这就是如何:

perlbrew use <version>

cpan -i <module>

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

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