当前位置:首页>科技>perl脚本如何执行在Linux和
发布时间:2026-07-23阅读(1)
编者荐语:
目前python已经火遍微信朋友圈广告以及公众号底部广告,各种洗脑广告大有追赶360借条之势,不过perl依然有广泛的基础,有很多生物软件需要依赖perl语言,很多人嘲笑写perl的落伍了,其实我们不仅会perl,还精通python,R……
以下文章来源于生信科技爱好者 ,作者沈维燕

生信科技爱好者
Bio IT 爱好者专栏,生物信息学与互联网科学技术分享。
Perl 是一种功能丰富的计算机程序语言,运行在超过 100 种计算机平台上,适用广泛,从大型机到便携设备,从快速原型创建到大规模可扩展开发。在生物信息分析领域,Perl 主要是做数据预处理、文本处理和格式转换、对算法效率要求不高的分析软件开发,系统管理和 pipeline 搭建等工作。这里对 Linux(主要是 CentOS)、Windows 下 Perl 的安装做一个备忘。
在官方网站下载新版本的源码包:http://www.perl.org/get.html,我下载的是 perl-5.26.1.tar.gz。
$tarzvxfperl-5.26.1.tar.gz$cdperl-5.26.1$./configure--helpUsage:Configure[-dehrsEKOSV][-fconfig.sh][-Dsymbol][-Dsymbol=value][-Usymbol][-Usymbol=][-Acommand:symbol...]-d:usedefaultsforallanswers.-e:goonwithoutquestioningpasttheproductionofconfig.sh.-f:specifyanalternatedefaultconfigurationfile.-h:printthishelpmessageandexit(withanerrorstatus).-r:reuseCsymbolsvalueifpossible(skipscostlynmextraction).-s:silentmode,onlyechoesquestionsandessentialinformation.-D:definesymboltohavesomevalue:-Dsymbolsymbolgetsthevaluedefine-Dsymbol=valuesymbolgetsthevaluevaluecommonusedexamples(seeINSTALLformoreinfo):-Duse64bitintuse64bitintegers-Duse64bitalluse64bitintegersandpointers-Dusethreadsusethreadsupport-Dinc_version_list=nonedonotincludeolderperltreesin@INC-DEBUGGING=noneDEBUGGINGoptions-Dcc=gccchooseyourcompiler-Dprefix=/opt/perl5chooseyourdestination-E:stopattheendofquestions,afterhavingproducedconfig.sh.-K:donotuseunlessyouknowwhatyouaredoing.-O:ignoredforbackwardcompatibility-S:performvariablesubstitutionsonall.SHfiles(canmixwith-f)-U:undefinesymbol:-Usymbolsymbolgetsthevalueundef-Usymbol=symbolgetscompletelyemptye.g.:-Uversiononly-A:manipulatesymbolaftertheplatformspecifichintshavebeenapplied:-Aappend:symbol=valueappendvaluetosymbol-Asymbol=valuelikeappend:,butwithaseparatingspace-Adefine:symbol=valuedefinesymboltohavevalue-Aclear:symboldefinesymboltobe-Adefine:symboldefinesymboltobedefine-Aeval:symbol=valuedefinesymboltobeevalofvalue-Aprepend:symbol=valueprependvaluetosymbol-Aundef:symboldefinesymboltobeundef-Aundef:symbol=definesymboltobee.g.:-Aprepend:libswanted=clpthread-Accflags=-DSOME_MACRO-V:printversionnumberandexit(withazerostatus).#设置源码$./Configure-des-Dprefix=/usr/local/software/Perl-5.26-Dusethreads-Uversiononly
$make......make[1]:***[IO.o]Error1make[1]:Leavingdirectory`/users/rmi1/build/perl-5.12.0/dist/IOUnsuccessfulmake(dist/IO):code=512atmake_ext.plline449.make:***[lib/auto/IO/IO.so]Error2
如果在 make 编译过程中出现如上报错,请参考 Make error when compiling Perl 5.12.1 (RHEL 5.5) 执行下面操作:
$makeclean$unsetC_INCLUDE_PATH$./Configure-des-Dprefix=/usr/local/software/Perl-5.26-Dusethreads-Uversiononly$make
继续验证编译,执行安装:
$maketest$makeinstall#命令完成后,基本安装就完成了
在 ~/.bashrc 中把 Perl 添加到 PATH 中,然后 source ~/.bashrc 刷新。
exportPATH="/usr/local/software/Perl-5.26/bin:$PATH"
$perl-versionThisisperl5,version26,subversion1(v5.26.1)builtforx86_64-linux-threadCopyright1987-2017,LarryWallPerlmaybecopiedonlyunderthetermsofeithertheArtisticLicenseortheGNUGeneralPublicLicense,whichmaybefoundinthePerl5sourcekit.CompleteDOCumentationforPerl,includingFAQlists,shouldbefoundonthissystemusing"manperl"or"perldocperl".IfyouhaveaccesstotheInternet,pointyourbrowserathttp://www.perl.org/,thePerlHomePage.
查看 Perl 配置汇总信息:
$perl-V#该命令会把对应perl配置、模块路径所有信息汇总打印出来Summaryofmyperl5(revision5version26subversion0)configuration:Platform:osname=linuxosvers=2.6.32-696.10.1.el6.x86_64......BuiltunderlinuxCompiledatSep17201716:35:49@INC:/usr/local/software/Perl-5.26/lib/perl5/site_perl/5.26.1/x86_64-linux/usr/local/software/Perl-5.26/lib/perl5/site_perl/5.26.1/usr/local/software/Perl-5.26/lib/perl5/5.26.1/x86_64-linux/usr/local/software/Perl-5.26/lib/perl5/5.26.1
在 Windows 下的 Perl 安装,我们推荐使用 ActivePerl,安装步骤如下。
ActivePerl:https://www.activestate.com/products/activeperl/
在这里我们下载 64-bit 的 Perl-5.26.3。
ActivePerl-5.26.3.2603-MSWin32-x64-a95bce075.exe 安装包下载完后,我们直接点击进行安装。

选择 "Custom" 自定义安装:

自定义安装路径:

把 Perl 添加到系统环境变量:

Perl 安装完成后,我们在 DOC 命令行输入 perl -V,可以看到详细的相关信息:

如果我们在安装过程中没有勾选把 Perl 添加到系统环境变量,DOC 中直接执行 perl -V 会出现 "perl is not recognized as an internal or external command" 提示,这时候我们需要手动把 Perl 添加到 Windows 的系统环境变量中就可以了。

为了更好对 Perl 进行扩展,方便以后的模块安装,我们最好配置一下 cpan。ActivePerl 有个好处就是在初始化 cpan 的时候会自动把 dmake、gcc、g 、mingw32-make 等 windows 常用的编译工具一起安装到 "$Dprefix/site/bin" 目录下,免去了我们手动安装这些编译器的各种麻烦。

到这里,windows 下的 ActivePerl(perl-5.26)就安装完成了!

Copyright © 2024 有趣生活 All Rights Reserve吉ICP备19000289号-5 TXT地图HTML地图XML地图