Perl模块利用CPAN在线安装自动化

需要解决2个问题:

1、  如何与CPAN交互:利用perl –MCPAN –e ‘install 模块’

2、  如何安装指定的版本:作者/模块-版本.tar.gz

How to install a specific version of a Perl module with CPAN

Mar 27, 2013 by David Farrell

Perl modules are usually installed via CPAN on the command line. This is invoked with the following syntax:

cpan My::Module

CPAN will always try to install the latest stable version of a module, which is a sensible default, however this may not always be the required behaviour. To have CPAN install a specific version of a module, you need to provide the full module distribution filename including the author. For example to install the module Set::Object version 1.28, at the command line type:

cpan SAMV/Set-Object-1.28.tar.gz

You can find the distribution filename for a module by searching for the module on CPAN.

 

 

 

 

完整例子:

#!/bin/sh

perl -MCPAN -e 'install "TIMB/DBI-1.639.tar.gz"' #安装DBI1.639版本

version=`perl -MDBI -e  'print DBI->VERSION'` #检查版本

if [ "$version" == "1.639" ]; then

        echo "install ok"

else

        echo "install fail"

fi

转载于:https://www.cnblogs.com/migrantworkers/p/8584428.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值