我得到这个错误:
找不到Foo。pm在@INC
有没有比下载、解压、制作等更简单的方法来安装它?
我得到这个错误:
找不到Foo。pm在@INC
有没有比下载、解压、制作等更简单的方法来安装它?
当前回答
cpan命令作为cpan Modulename
$ cpan HTML::Parser
要自动安装依赖项,请执行以下操作
$ perl -MCPAN -e shell
cpan[1]> o conf prerequisites_policy follow
cpan[2]> o conf commit
exit
我更喜欢App::cpanminus,它会自动安装依赖项。只做
$ cpanm HTML::Parser
其他回答
在ubuntu上,大多数perl模块都已经打包好了,所以安装要比其他大多数需要编译的系统快得多。
例如,要在命令提示符下安装Foo::Bar,你通常只需要:
sudo apt-get install libfoo-bar-perl
遗憾的是,并非所有模块都遵循这种命名约定。
在带有Perl的ActiveState发行版的Windows上,使用ppm命令。
有几个人提到了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.
sudo perl -MCPAN -e安装Foo
我知道的两种方法:
使用PPM:
在Windows (ActivePerl)中,我使用ppm
从命令行输入ppm。在ppm提示符下…
ppm> install foo
or
ppm> search foo
获取可用的foo模块列表。为所有命令键入help
使用cpan:
你也可以这样使用CPAN (*nix系统):
perl -MCPAN -e 'shell'
给你一个提示
cpan>
听到提示音…
cpan> install foo (again to install the foo module)
输入h以获得cpan的命令列表