我得到这个错误:

找不到Foo。pm在@INC

有没有比下载、解压、制作等更简单的方法来安装它?


当前回答

简单地在shell上执行cpan Foo::Bar就可以达到这个目的。

其他回答

在带有Perl的ActiveState发行版的Windows上,使用ppm命令。

已经回答和接受的答案-但不管怎样:

以我之见,安装CPAN模块最简单的方法(在unix类系统上,不了解windows)是:

curl -L http://cpanmin.us | perl - --sudo App::cpanminus

上面是安装称为cpanm的“零配置CPAN模块安装程序”。(可能需要几分钟来安装-不要打断这个过程)

And after - simply:

cpanm Foo
cpanm Module::One
cpanm Another::Module

在Fedora Linux或Enterprise Linux上,yum还跟踪perl库依赖关系。因此,如果perl模块可用,并且某些rpm包导出该依赖项,它将为您安装正确的包。

yum install 'perl(Chocolate::Belgian)'

(很可能是perl- chocolate - belgium包,甚至是ChocolateFactory包)

有几个人提到了cpan实用程序,但它不仅仅是启动一个shell。只要给它你想安装的模块,让它做它的工作。

$prompt> cpan Foo::Bar

如果你不给它任何参数,它就会启动CPAN。点壳。这可以在Unix、Mac上工作,在Windows上应该也可以(特别是Strawberry Perl)。

cpan工具还可以做其他一些事情。下面是当前特性的总结(可能比CPAN附带的特性更新)。PM和perl):

-a
Creates the CPAN.pm autobundle with CPAN::Shell->autobundle.

-A module [ module ... ]
Shows the primary maintainers for the specified modules

-C module [ module ... ]
Show the Changes files for the specified modules

-D module [ module ... ]
Show the module details. This prints one line for each out-of-date module (meaning,
modules locally installed but have newer versions on CPAN). Each line has three columns:
module name, local version, and CPAN version.

-L author [ author ... ]
List the modules by the specified authors.

-h
Prints a help message.

-O
Show the out-of-date modules.

-r
Recompiles dynamically loaded modules with CPAN::Shell->recompile.

-v
Print the script version and CPAN.pm version.

另请参见Yes,即使您也可以使用CPAN。它展示了如何在没有root或sudo访问权限的情况下使用CPAN。