我得到这个错误:
找不到Foo。pm在@INC
有没有比下载、解压、制作等更简单的方法来安装它?
我得到这个错误:
找不到Foo。pm在@INC
有没有比下载、解压、制作等更简单的方法来安装它?
当前回答
如果您希望将新模块放入cpan shell未配置为使用的自定义位置,那么以下操作可能会很方便。
#wget <URL to the module.tgz>
##unpack
perl Build.PL
./Build destdir=$HOME install_base=$HOME
./Build destdir=$HOME install_base=$HOME install
其他回答
简单地在shell上执行cpan Foo::Bar就可以达到这个目的。
奥托提了个好建议。这也适用于Debian,以及任何其他Debian衍生物。缺失的部分是当apt-cache搜索没有找到一些东西时该怎么做。
$ sudo apt-get install dh-make-perl build-essential apt-file
$ sudo apt-file update
然后,当你有一个随机的模块,你想安装:
$ cd ~/some/path
$ dh-make-perl --build --cpan Some::Random::Module
$ sudo dpkg -i libsome-random-module-perl-0.01-1_i386.deb
这将给你一个deb包,你可以安装它来获得Some::Random::Module。这里最大的好处之一是,除了模块本身之外,手册页和示例脚本将被放置在您的发行版所选择的位置。如果发行版发布了新版本的Some::Random::Module的官方包,它将在你apt-get升级时自动安装。
sudo perl -MCPAN -e安装Foo
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
在Unix:
通常你在shell中开始cpan:
全面美元
和类型
安装巧克力::比利时
简而言之:
巧克力cpan::比利时
在Windows上:
如果您在Windows上使用ActivePerl, PPM (Perl包管理器)有许多与cpa .pm相同的功能。
例子:
ppm美元 Ppm >搜索net-smtp 安装Net-SMTP-Multipart
参见如何安装Perl模块?在CPAN常见问题解答中
许多发行版以包的形式发布了大量perl模块。
Debian/Ubuntu: apt-cache search 'perl$' Arch Linux: pacman -Ss '^perl-' Gentoo: category dev-perl
您应该总是喜欢它们,因为您可以从自动(安全)更新和易于删除中受益。这对于cpan工具本身来说是相当棘手的。
对于Gentoo,有一个很好的工具叫做g-cpan,它可以从CPAN构建/安装模块,并为你创建一个Gentoo包(ebuild)。