Chinaunix首页 | 论坛 | 博客
  • 博客访问: 616895
  • 博文数量: 140
  • 博客积分: 2635
  • 博客等级: 少校
  • 技术积分: 1353
  • 用 户 组: 普通用户
  • 注册时间: 2010-06-04 15:46
文章分类
文章存档

2015年(2)

2014年(12)

2013年(10)

2012年(10)

2011年(85)

2010年(21)

分类:

2010-06-30 18:14:52

1.下载 bindgraph 

解压缩文件 

通过阅读README,配置需要的文件。

nice -20 ./bindgraph.pl --daemon --logfile /var/log/query.log

如果提示:Can't locate File/Tail.pm in @INC

解决方法:这是Perl语言发展史上 

的一个里程碑。此后,广大自由软件爱好者开发了大量功能强大、构思精巧的Perl模块,极大地 

扩展了Perl语言的功能。CPANComprehensive Perl Archive Network)是internetPerl模块 

最大的集散地,包含了现今公布的几乎所有的perl模块。 

    几个主要的CPAN站点有: 

    国内:ftp://freesoft.cgi.gov.cn/pub/languages/perl/CPAN 

           

    国外: 

           

    我在这里介绍一下各种平台下perl模块的安装方法。以安装DBI模块为例。 

1Linux/Unix下的安装方法: 

    Linux/Unix下安装Perl模块有两种方法:手工安装和自动安装。第一种方法是从CPAN上下载 

您需要的模块,手工编译、安装。第二种方法是联上internet,使用一个叫做CPAN的模块自动完 

成下载、编译、安装的全过程。 

a、手工安装的步骤: 

CPAN下载了DBI模块1.13版的压缩文件DBI-1.13.tar.gz,假设放在/usr/local/src/下。 

cd /usr/local/src 

解压缩这个文件: 

tar xvzf DBI-1.13.tar.gz 

这时会新建一个DBI-1.13的目录。 

cd DBI-1.13 

生成makefile: 

perl Makefile.PL 

建立模块 

make 

测试模块 

make test 

如果测试结果报告“all test ok”,您就可以放心地安装编译好的模块了。安装模块前,先要 

确保您对perl5安装目录有可写权限(通常以su命令获得),执行: 

make install 

现在,写个程序试试吧。 

#!/usr/bin/perl -w 

use strict; 

use DBI; 

..

    上述步骤适合于Linux/Unix下绝大多数的Perl模块。可能还有少数模块的安装方法略有差别, 

所以最好先看看安装目录里的READMEINSTALL。另外,上述过程是针对动态链接的Perl编译 

器(所有Linux下预安装的Perl都是动态链接的),如果您在使用一个静态链接的Perl,您需要将 

新的模块静态链接到perl编译器中,可能还需要重启机器。

b、使用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 

2Win32下的安装方法: 

    在Win32下,建议使用ActiveStatePerl for Win32,即ActivePerlActivePerl的主页在: 

 。在Win32下,最好也使用专门为ActivePerl定制的Perl模块。从 

CPAN下载的Perl模块不能很好地在ActivePerl下使用。类似于CPAN模块,ActiveState也开发 

了一个自动安装工具叫做PPMPerl Package Manager)。 

最通常的安装方法是: 

首先联上线 

dos命令行下启动ppm 

ppm 

获得帮助 

PPM>h 

列出ActiveState站点上所有为Perl模块的清单。 

PPM>search 

安装模块 

PPM>install DBI 

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

退出 

PPM>q 

如果您的机器位于防火墙之后,通过http代理上网,那么可以使用下面的方法。 

对于老的基于perl 5.005ActivePerl版本(ActivePerl 522以下版本,不包括ActivePerl 522),从 

下载您需要的Perl模块,例如DBI.zip。 

将其解压缩在C:\TEMP\DBI下 

cd \TEMP\DBI 

ppm install DBI.PPD 

最新的基于perl 5.6ActivePerl版本(ActivePerl 613及以上版本)的安装方法略有不同。安 

ActivePerl 613前需要先安装MicrosoftWindows Installer。 

Windows Installer从这里下载: 

 

ActivePerl 613从这里下载: 

… ePerl-5.6.0.613.msi 

对于基于perl 5.6ActivePerl版本,从 

PPMPackages/5.6/ 

下载您需要的Perl模块的安装描述文件,例如DBI.PPD 

安装模块前需要先联上线 

ppm install DBI.PPD。  

If you are already familiar with installing CPAN modules, go-perl is no different from any other. If you arent, you may wish to experiment now.

Try typing the following:

perl -MCPAN -e shell

install GO::Parser

The following may also work:

cpan GO::Parser

If this is the first time using the CPAN installer, you will be asked a barrage of questions. You are best to answer with the defaults – you can always change this later.

If you do NOT have access to the system-wide perl directories on your system (these will typically be in /Library or /usr/local), then you should either get some help setting up CPAN for use with your system, OR you should follow an alternate protocol below. (You may wish to modify the value of PREFIX to ~ in the CPAN setup, as detailed in protocol III)

If you are on OS X you may need to do this:

sudo cpan GO::Parser

Providing you do have write-access to these directories, the above commands should hopefully go smoothly. When installing go-perl, you may be asked if you wish to also install Data::Stag and IO::String – you should answer yes

After this, you should be ready to use go-perl! The scripts should be in your path and the libraries should be in the standard place. You may wish to start by trying map2slim” or go2obo_xml

There are certain applications that require additional third-party modules. All these are available from CPAN, and can be installed in the above manner. For example, if you try and use the go-filter-subset.pl script to generate a PNG image of an ontology subgraph, the system will complain you do not have the module GraphViz” installed. To install this, simply type:

perl -MCPAN -e shell

install GraphViz

Depending on what you use go-perl for, you may not ever need to install other CPAN modules

Trackback : http://wanguan2000.blog.ubuntu.org.cn/2009/02/12/%E4%BD%BF%E7%94%A8cpan%E5%AE%89%E8%A3%85perl%E6%A8%A1%E5%9D%97/

阅读(2092) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~