perl模块安装
转自:
http://www.cnblogs.com/itech/archive/2009/08/10/1542832.html
http://www.mike.org.cn/blog/index.php?load=read&id=643
Perl 到了第五版增加了模块的概念,用来提供面向对象编程的能力。这是 Perl 语言发展史上的一个里程碑。此后,广大自由软件爱好者开发了大量功能强大、构思精巧的 Perl 模块,极大地扩展了 Perl 语言的功能。CPAN(Comprehensive Perl Archive Network)是Perl模块最大的集散地,包含了现今公布的几乎所有的perl模块。
安装方法
我在这里介绍一下各种平台下 perl 模块的安装方法。以安装Net-Server模块为例。
一 Linux/Unix下安装Perl模块有两种方法:手工安装和自动安装。
第一种方法是从CPAN上下载您需要的模块,手工编译、安装。第二种方法是使用CPAN模块自动完成下载、编译、安装的全过程。
A、手工安装的步骤:
从 CPAN(http://search.cpan.org/)下载了Net-Server模块0.97版的压缩文件Net-Server-0.97.tar.gz,假设放在/usr/local/src/下。
cd /usr/local/src
解压缩这个文件,这时会新建一个Net-Server-0.97的目录。
tar xvzf Net-Server-0.97.tar.gz
换到解压后的目录:
cd Net-Server-0.97
生成 makefile:
perl Makefile.PL
生成模块:make
测试模块(这步可有可无):
make test
如果测试结果报告“all test ok”,您就可以放心地安装编译好的模块了。
安装模块前,先要确保您对 perl5 安装目录有可写权限(通常以 su 命令获得),执行:
make install
现在,试试 DBI 模块吧。如果下面的命令没有给出任何输出,那就没问题。
$>perl -MNet::Server -e1
上述步骤适合于 Linux/Unix下绝大多数的Perl模块。可能还有少数模块的安装方法略有差别,所以最好先看看安装目录里的 README 或 INSTALL。
有的时候如果是build.pl的需要以下安装步骤:(需要Module::Build模块支持)
perl Build.PL
./Build
./Build test
./Build install
B、使用CPAN模块自动安装方法一:
安装前需要先联上网,并且您需要取得root权限。
perl -MCPAN -e shell
初次运行CPAN时需要做一些设置,如果您的机器是直接与因特网相联(拨号上网、专线,etc.),那么一路回车就行了,只需要在最后一步选一个离您最近的 CPAN 镜像站点。例如我选的是位于国内的http://www.cnblogs.com/itech/admin/ftp://www.perl87.cn/CPAN/ 。否则,如果您的机器位于防火墙之后,还需要设置ftp代理或http代理。下面是常用 cpan 命令。
获得帮助
cpan>help
列出CPAN上所有模块的列表
cpan>m
安装模块,自动完成Net::Server模块从下载到安装的全过程。
cpan>install Net::Server
退出
cpan>quit
C、使用CPAN模块自动安装方法二:
cpan -i 模块名
例如:cpan -i Net::Server
二 windows上perl模块安装
A 手动(跟Linux类似) [解压后 perl makefile.pl nmake/dmake nmake/dmake install]
nmake需要cd C:\Program Files\Microsoft Visual Studio X\VC\bin and execute vcvars32.bat;然后执行nmake;
dmake 貌似是cpan环境配置好就有了在C:\Perl\site\bin下。
B Cpan (安装前需要对cpan配置,cpan需要安装其他的模块dmake和MinGw gcc compiler) (跟Linux类似)
C 如果使用ActivePerl,可以使用PPM(巧记Perl install PM module)来安装,使用PPM GUI或PPM Commandline。一般安装在site\lib下
PPM commandline实例如下:
a) add correct repositories..
c:\perl\bin\ppm repo add http://theoryx5.uwinnipeg.ca/ppms/package.lst
c:\perl\bin\ppm repo add http://www.roth.net/perl/packages/
b) add the packages
c:\perl\bin\ppm install Carp-Assert
c:\perl\bin\ppm install Log-Log4perl
c:\perl\bin\ppm install YAML-Syck
或
ppm install Path::Class
三 几个主要的CPAN站点有:
国内:
最新更新请查阅 http://cpan.org/SITES.html
http://www.perl87.cn/CPAN/ 网页镜像
http://www.cnblogs.com/itech/admin/ftp://www.perl87.cn/CPAN/ 模块镜像
国外:http://www.cpan.org/
四 使用cpan和ppm安装时要注意模块名字的大小写
五 To get a list of the standard pragmatics(相当于c的宏定义) and modules, see perldoc perlmodlib.
我们可以直接输入 perldoc perlmodlib 来查看pragmatics和modules
Pragmatic Modules
They work somewhat like compiler directives (pragmata) in that they tend
to affect the compilation of your program, and thus will usually work well
only when used within a "use", or "no". Most of these are lexically
scoped, so an inner BLOCK may countermand them by saying: no integer;
no strict 'refs';
no warnings; which lasts until the end of that BLOCK. Some pragmas are lexically scoped--typically those that affect the $^H
hints variable. Others affect the current package instead, like "use vars"
and "use subs", which allow you to predeclare a variables or subroutines
within a particular file rather than just a block. Such declarations are
effective for the entire file for which they were declared. You cannot
rescind them with "no vars" or "no subs".
Standard Modules
Standard, bundled modules are all expected to behave in a well-defined
manner with respect to namespace pollution because they use the Exporter
module. See their own documentation for details. To find out all modules installed on your system, including those without
documentation or outside the standard release, just use the following
command (under the default win32 shell, double quotes should be used
instead of single quotes). % perl -MFile::Find=find -MFile::Spec::Functions -Tlwe \
'find { wanted => sub { print canonpath $_ if /\.pm\z/ },
no_chdir => }, @INC'
(The -T is here to prevent '.' from being listed in @INC.) They should all
have their own documentation installed and accessible via your system
man() command. Note also that the command "perldoc perllocal" gives you a (possibly
incomplete) list of the modules that have been further installed on your
system. (The perllocal.pod file is updated by the standard MakeMaker
install process.)
Extension Modules
Extension modules are written in C (or a mix of Perl and C). They are
usually dynamically loaded into Perl if and when you need them, but may
also be linked in statically. Supported extension modules include Socket,
Fcntl, and POSIX. Many popular C extension modules do not come bundled (at least, not
completely) due to their sizes, volatility, or simply lack of time for
adequate testing and configuration across the multitude of platforms on
which Perl was beta-tested. You are encouraged to look for them on CPAN
(described below), or using web search engines like Alta Vista or Google.
perl模块安装的更多相关文章
- Linux CPAN Perl 模块安装
当我们想使用某些Perl模块的时候,很可能会遇到当前系统不存在这个模块的情况,这时我们可以通过使用CPAN来对相应的模块进行获取,下面就介绍一下CPAN的使用方法.首先,我们可以用perl -e 'u ...
- centos7 cpanm安装,及perl模块安装
1. cpan安装 yum安装 yum install perl-App-cpanminus.noarch 注意:安装完成后,root及非root用户都可以使用cpanm安装模块,root用户直接用c ...
- Linux下perl模块安装
perl模块下载地址: http://search.cpan.org/ 假设放在/usr/local/src/下 cd /usr/local/src 上传下载的压缩包CGI-Session-3.95. ...
- ---perl 模块安装方法
http://blog.csdn.net/lincy100/article/details/7333794 $ perl -MCPAN -e shell install Log::Log4perlin ...
- perl 模块安装
You can check if you have them installed in your machine with: > perl -e 1 -M<module> It wi ...
- perl模块安装——cpanm
下载 wget http://xrl.us/cpanm mv cpanm.1 cpanm 配置 在bashrc或zshrc里面加入下面的几句话 最好把相对路径改成绝度路径(将~换成你根目录的绝对路径 ...
- perl 简单学习,安装perl模块
检查是否安装了某个perl模块 有多种方式 0.perldoc perlinstall 列出所有的模块及版本号 1. perl -M模块名 -e 1(模块名不加空格) 没有返回值则说明有此模块 2.p ...
- 非[无]root权限 服务器 下安装perl以及perl模块--转载
转载自http://www.zilhua.com 在本博客中,所有的软件安装都在服务器上,且无root权限.理论上适合所有的用户. 我的安装目录 cd /home/zilhua/software 1. ...
- 非[无]root权限 服务器 下安装perl以及perl模块
转载自http://www.zilhua.com 在本博客中,所有的软件安装都在服务器上,且无root权限.理论上适合所有的用户. 我的安装目录 cd /home/zilhua/software 1. ...
随机推荐
- PHP截取含中文的混合字符串长度的函数
截取含中文的混合字符串长度 /** * 截取中文混合字符串指定长度 * * @param string $string * @param integer $length * @param string ...
- IE中float元素如果同时设置了margin值,此时margin的值会变为双倍的解决方法
IE中float元素如果同时设置了margin值,此时margin的值会变为双倍, 解决办法: 是在该元素中加入display:inline.
- Java 反射 Method的invoke回调调用任意方法
Java 反射 Method的invoke回调调用任意方法 @author ixenos 关键子:Method.Field.invoke方法指针/函数指针.回调函数 invoke回调流程示例 0.由C ...
- Llinux环境下编译并使用OpenCV
http://docs.opencv.org/2.4/doc/tutorials/introduction/linux_install/linux_install.html http://stacko ...
- s=a+aa+aaa+aaaa+aa...aaaa
main(){ int a,n,count=1; long int sn=0,tn=0; cout<<"input a and n:"; cin>>a> ...
- Mainline/Stable/Legacy
Nginx官网提供了三个类型的版本Mainline version:Mainline 是 Nginx 目前主力在做的版本,可以说是开发版Stable version:最新稳定版,生产环境上建议使用的版 ...
- 万航单位换算器 V1.0 绿色版
软件名称: 万航单位换算器软件语言: 简体中文授权方式: 免费软件运行环境: Win 32位/64位软件大小: 347KB图片预览: 软件简介:万航单位换算器是一个可以随意转换单位的绿色软件,这个软件 ...
- IE6下a标签失效(背景穿透)
background:fixed url(about:blank);有时候做感应区域的时候在ie6下不给背景就会感应不到,比如说当鼠标移到图片的左半边部分,鼠标手势变成向左的箭 头,比如说有些时候a标 ...
- 获取Camera 支持视频的尺寸
<uses-permission android:name="android.permission.CAMERA" > </uses-permission> ...
- python初识1
作者:武沛齐 出处:http://www.cnblogs.com/wupeiqi/ 本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接. 安装Pyt ...