luria的个人博客分享 http://blog.sciencenet.cn/u/luria

博文

perl的更新与模块的安装

已有 9452 次阅读 2017-7-26 12:56 |个人分类:BioIT|系统分类:科研笔记| Perl, not, This, perl多线程

perl更新

有很多生信软件用perl语言来写,而且会用到一些perl模块。编程语言的模块一直被认为是把双刃剑,弊端之一是有些模块的安装比较麻烦。闲言少述,这里提供了perl的更新代码(跳过多线程的坑)以及基本的perl模块安装方法。

我们在安装perl软件的时候经常会遇到“This Perl not built to support threads”这样的错误提示。一直不太明白在多线程软件逐渐形成主流的今天,perl却从5.8.0版之后,默认安装均不启用多线程,这真是一个巨大的坑! 安装多线程版的perl如下:

wget http://www.cpan.org/src/5.0/perl-5.16.1.tar.gz
tar -xzf perl-5.16.1.tar.gz
cd perl-5.16.1
./Configure -des -Dprefix=/usr/local/perl -Dusethreads -Uinstalluserbinperl
make
make test
make install
mv /usr/bin/perl /usr/bin/perl.bak
ln -s /usr/local/perl/bin/perl /usr/bin/perl

# 运行完如果输入perl -v能正常显示,则表示安装成功

# ./Configure这一行参考自[1],其中各选项解释如下(可通过./Configure -h查看):

-des -d -e -s的合写。其中-d表示未指定的选项均按默认值,-e表示执行config.sh过程中不显示出现的警告,-s表示静默安装,仅打印出错误信息或必要信息。

-Dusethreads 支持多线程(use thread support),[注:这是这段代码的核心。]

-Dprefix=/opt/perl5 指定perl安装位置(choose your destination),默认是安装到/opt/perl5中,这里通常的做法先安装到/usr/local/,再将perl主程序链接到/usr/bin/中。考虑到安装可能发生意外,或者某些软件需要使用低版本的perl运行,建议备份原始的perl,再将新的perl并设为默认,而不是直接覆盖。

-Uinstalluserbinperl 表示在安装的时候不要用新的perl直接覆盖/usr/bin/perl

You'll also need to tell Configure not to link this new Perl as /usr/bin/perl with -Uinstallusrbinperl

另外,看到博文[2]中,还有一个选项-Dcc=gcc它指定使用的编译器(choose your compiler),因为默认值即为gcc,这个选项没有必要加。

perl模块安装

A.使用cpan安装

一些用Perl写的软件安装时经常出现某模块没有安装,如下:

从提示中我们发现是Archive::Extract这个模块没有安装。

安装的方法如下:

[推荐] sudo cpan Archive::Extract

# 新版的cpan不需要用cpan install module, 只需cpan module

此外还有

perl -MCPAN -e install "install Archive::Extract"

#注意引号

B.使用原码安装

搜索perl模块的重要网址:

http://search.cpan.org/

https://metacpan.org/  

从以上提供perl模块的网站下载模块的压缩包,以XML:Simple为例(参考〔3〕。 这个模块会在trinity下游分析的软件中用到)。

在CPAN中搜索到http://search.cpan.org/~grantm/XML-Simple-2.24/lib/XML/Simple.pm。在页面右侧会有一个Download链接,通过该链接下载到tar.gz压缩包(XML-Simple-2.24.tar.gz)。

tar -zxvf XML-Simple-2.24.tar.gz

cd XML-Simple-2.24

perl Makefile.PL

make

make test

make install


以下网址也提供了一些perl的学习材料

http://perldoc.perl.org/index.html


参考材料

[1] https://www.perl.com/pub/2002/09/04/threads.html

[2] http://blog.csdn.net/zzq900503/article/details/16948349

[3] http://www.mclean.net.nz/cpan/



https://blog.sciencenet.cn/blog-2970729-1068147.html

上一篇:Bowtie2和Samtools软件更新
下一篇:rank abundance 解析
收藏 IP: 58.62.3.*| 热度|

0

该博文允许注册用户评论 请点击登录 评论 (0 个评论)

数据加载中...

Archiver|手机版|科学网 ( 京ICP备07017567号-12 )

GMT+8, 2024-4-17 04:01

Powered by ScienceNet.cn

Copyright © 2007- 中国科学报社

返回顶部