转自:

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 来查看pragmaticsmodules

  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模块安装的更多相关文章

  1. Linux CPAN Perl 模块安装

    当我们想使用某些Perl模块的时候,很可能会遇到当前系统不存在这个模块的情况,这时我们可以通过使用CPAN来对相应的模块进行获取,下面就介绍一下CPAN的使用方法.首先,我们可以用perl -e 'u ...

  2. centos7 cpanm安装,及perl模块安装

    1. cpan安装 yum安装 yum install perl-App-cpanminus.noarch 注意:安装完成后,root及非root用户都可以使用cpanm安装模块,root用户直接用c ...

  3. Linux下perl模块安装

    perl模块下载地址: http://search.cpan.org/ 假设放在/usr/local/src/下 cd /usr/local/src 上传下载的压缩包CGI-Session-3.95. ...

  4. ---perl 模块安装方法

    http://blog.csdn.net/lincy100/article/details/7333794 $ perl -MCPAN -e shell install Log::Log4perlin ...

  5. perl 模块安装

    You can check if you have them installed in your machine with: > perl -e 1 -M<module> It wi ...

  6. perl模块安装——cpanm

    下载 wget  http://xrl.us/cpanm mv cpanm.1 cpanm 配置 在bashrc或zshrc里面加入下面的几句话 最好把相对路径改成绝度路径(将~换成你根目录的绝对路径 ...

  7. perl 简单学习,安装perl模块

    检查是否安装了某个perl模块 有多种方式 0.perldoc perlinstall 列出所有的模块及版本号 1. perl -M模块名 -e 1(模块名不加空格) 没有返回值则说明有此模块 2.p ...

  8. 非[无]root权限 服务器 下安装perl以及perl模块--转载

    转载自http://www.zilhua.com 在本博客中,所有的软件安装都在服务器上,且无root权限.理论上适合所有的用户. 我的安装目录 cd /home/zilhua/software 1. ...

  9. 非[无]root权限 服务器 下安装perl以及perl模块

    转载自http://www.zilhua.com 在本博客中,所有的软件安装都在服务器上,且无root权限.理论上适合所有的用户. 我的安装目录 cd /home/zilhua/software 1. ...

随机推荐

  1. Linux系统VPS/服务器安装WINDOWS桌面环境可以采用的几个方法

    我们公司的几个项目需要在WINDOWS桌面类型的界面操作,哪怕仅有一个浏览器远程操作也是可以的,我们运维部门得到的任务就是需要能在已有的Linux系统的VPS.服务器环境中能够远程操作,至少需要能可以 ...

  2. javaWEB总结(12):JSP页面的九个隐含对象

    前言 jsp本质上是一个servlet,而在jsp中有九个不用声明就可以使用的对象,我们叫他隐含对象.本文基于上文所写,如有需要可查看上一篇文章javaWEB总结(11):JSP简介及原理. 打开上次 ...

  3. ASP.NET Page执行顺序

    using System; using System.Data; using System.Configuration; using System.Web; using System.Web.Secu ...

  4. EconomicIndoor集成测试

    加密时序列号相同引发的呼叫功能异常 现象描述: 配置完房间号一次性呼叫问题 问题描述: 两台室内机升级后配置到同一门口机, 各种配置正确. 作为主叫呼不出去, 作为被叫可以接听, 每修改一次房间号, ...

  5. oracle 写入txt

    分几个步骤 1,创建输出路径,比如你要在/orcl/dir目录下输出,你就先要建立好这个路径,并在root用户下 chmod 777 /orcl/dir 2,sqlplus下以sysdba登录,执行以 ...

  6. (负)-margin在页面布局中的应用

    有关margin的原理可以看看这篇文章:http://www.cnblogs.com/2050/archive/2012/08/13/2636467.html#2457812 有关margin负值的几 ...

  7. 分享给大家一个简单的数据导出excel类

    <?php /** * 生成excel文件操作 * * @author wesley wu * @date 2013.12.9 */ class Excel { private $limit = ...

  8. jQuery 截取double数据 重新赋值

    $('.prioritySort').each(function(i){ $(this).text($(this).text().substring(0,$(this).text().indexOf( ...

  9. Django剖析

    $django-admin startproject mysite  创建一个django新工程 $python manage.py runserver 开启该服务器 $python manage.p ...

  10. 一步一步学EF系列2【最简单的一个实例】

    整个文章我都会用最简单,最容易让人理解的方式给大家分享和共同学习.(由于live Writer不靠谱 又得补发一篇) 一.安装 Install-Package EntityFramework 二.简单 ...