[perl] Linux终端 / 命令行安装Perl模块

本文介绍如何在Linux环境中使用CPAN模块进行自动化安装。包括获取root权限、配置CPAN、选择镜像站点及设置代理等内容,并演示了安装DBI模块的具体步骤。

在Linux终端上,使用CPAN模块自动安装 

安装前需要先联上线,并且您需要取得root权限。 
perl -MCPAN -e shell 
初次运行CPAN时需要做一些设置,如果您的机器是直接与internet相联(拨号上网、专线,etc.), 
那么一路回车就行了,只需要在最后选一个离您最近的CPAN镜像站点。例如我选的是位于国内的 
中国自由软件库ftp://freesoft.cgi.gov.cn/pub/languages/perl/CPAN 。否则,如果您的机器
位于防火墙之后,还需要设置ftp代理或http代理。 

获得帮助 
cpan>h 

列出CPAN上所有模块的列表 
cpan>m 

安装模块 
cpan>install DBI 
自动完成DBI模块从下载到安装的全过程。 

退出 
cpan>q

转载于:https://www.cnblogs.com/xiaofeiIDO/p/6550475.html

windows下安装perl模块方法和必备软件nmake dmake devcpp: 方式一: 将 nmake.exe 放到system32目录下 用一下方式: perl Makefile.pl nmake nmake test nmake install 如果成功,将不用看下面内容。 方式二: 手动编译方式 优点:通吃所有模块 缺点:有点麻烦 具体步骤:1安装编译器2设置编译器的环境变量3可能安装dmake 具体方法:如下 1.首先要有个c编译器,推荐dev-cpp(开源免费的,网上自己搜索),记得要下含有mingw的就是了(不懂c,下载含有mingw的因为这个版本的bin目录里有gcc.exe等工具). 1.1安装好了编译器之后,要能在cmd中以命令方式运行的话,必须要设置环境变量,在winxp中[我的电脑]->[属性]->[高级]->[环境变量]里设置,只需要在path里加个你路径,比如你的安装路径是c:\dev-cpp,那你就要加上c:\dev-cpp\bin (path中有很多其他的路径,之间记得用;隔开 )弄完好,在cmd中运行gcc -v 显示出内容表示编译器安装成功,并且可以用命令行编译. 2.编译步骤,在cpan上下载需要的模块,比如Win32::SerialPort,下载好了解压,在cmd中进入这个目录(简单的dos命令应该知道吧),就用常见的方法: perl Makefile.pl make make test make install 如果成功,将不用看下面内容。 方式三: 使用方式二make很可能会出现错误,不能编译,找了很多原因,有高人介绍了解决办法,就是下载一个叫dmake的工具,解压缩,将里面的dmake.exe和startup的文件夹(好象是这个名字)一起复制到c:\dev-cpp\bin 里(因为这个目录注册到环境变量里的),之后安装改成: perl Makefile.pl dmake dmake test dmake install 注意: 如果安装过oracle10g你将会发现出现版本冲突的情况。 解决方案如下:修改%PERL5LIB%环境变量,修改为perl所在目录
bash: error while loading shared libraries: libtinfo.so.5: cannot open shared object file: No such file or directory bash: error while loading shared libraries: libtinfo.so.5: cannot open shared object file: No such file or directory awk: error while loading shared libraries: libreadline.so.6: cannot open shared object file: No such file or directory bash: error while loading shared libraries: libtinfo.so.5: cannot open shared object file: No such file or directory bash: error while loading shared libraries: libtinfo.so.5: cannot open shared object file: No such file or directory awk: error while loading shared libraries: libreadline.so.6: cannot open shared object file: No such file or directory Collecting package info: merging...awk: error while loading shared libraries: libreadline.so.6: cannot open shared object file: No such file or directory Collecting package info: done awk: error while loading shared libraries: libreadline.so.6: cannot open shared object file: No such file or directory bash: error while loading shared libraries: libtinfo.so.5: cannot open shared object file: No such file or directory bash: error while loading shared libraries: libtinfo.so.5: cannot open shared object file: No such file or directory awk: error while loading shared libraries: libreadline.so.6: cannot open shared object file: No such file or directory Collecting target info: merging...awk: error while loading shared libraries: libreadline.so.6: cannot open shared object file: No such file or directory Collecting target info: done Can't locate FindBin.pm in @INC (you may need to install the FindBin module) (@INC contains: /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.22.1 /usr/local/share/perl/5.22.1 /usr/lib/x86_64-linux-gnu/perl5/5.22 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.22 /usr/share/perl/5.22 /usr/local/lib/site_perl /usr/lib/x86_64-linux-gnu/perl-base .) at ./scripts/metadata.pl line 2. BEGIN failed--compilation aborted at ./scripts/metadata.pl line 2. Failed to build tmp/.config-package.in Argument "4.2.1" isn't numeric in numeric ge (>=) at ./scripts/feeds line 25. Can't locate FindBin.pm in @INC (you may need to install the FindBin module) (@INC contains: /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.22.1 /usr/local/share/perl/5.22.1 /usr/lib/x86_64-linux-gnu/perl5/5.22 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.22 /usr/share/perl/5.22 /usr/local/lib/site_perl /usr/lib/x86_64-linux-gnu/perl-base .) at ./scripts/metadata.pl line 2. BEGIN failed--compilation aborted at ./scripts/metadata.pl line 2. make[1]: *** [/home/zjc/openwrt/include/toplevel.mk:75: prepare-tmpinfo] Error 1 make: *** [/home/zjc/openwrt/include/toplevel.mk:181: world] Error 2
最新发布
08-07
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值