升级系统自带的perl

简介:

CentOS 系统自带的Perl版本是5.8.8,已经很老了,哥今天折腾一下,把它升级到最新版本。

系统初始状态下的Perl版本

 
  1. # perl -v 
  2.  
  3. This is perl, v5.8.8 built for x86_64-linux-thread-multi 
  4.  
  5. Copyright 1987-2006, Larry Wall 
  6.  
  7. Perl may be copied only under the terms of either the Artistic License or the 
  8. GNU General Public License, which may be found in the Perl 5 source kit. 
  9.  
  10. Complete documentation for Perl, including FAQ lists, should be found on 
  11. this system using "man perl" or "perldoc perl".  If you have access to the 
  12. Internet, point your browser at http://www.perl.org/, the Perl Home Page. 

看一下perl安装在哪

 
  1. # which perl 
  2. /usr/bin/perl 
  3. # ll /usr/bin/perl 
  4. -rwxr-xr-x 2 root root 19200 Jan 21  2009 /usr/bin/perl 

接下来,准备升级操作,下载最新的perl源码包到本地来

 
  1. http://www.cpan.org/src/5.0/perl-5.14.1.tar.gz 

安装

 
  1. # tar perl-5.14.1.tar.gz 
  2. # cd perl-5.14.1 
  3. # ./Configure --help 
  4. Usage: Configure [-dehrsEKOSV] [-f config.sh] [-D symbol] [-D symbol=value
  5.                  [-U symbol] [-U symbol=] [-A command:symbol...] 
  6.   -d : use defaults for all answers. 
  7.   -e : go on without questioning past the production of config.sh. 
  8.   -f : specify an alternate default configuration file. 
  9.   -h : print this help message and exit (with an error status). 
  10.   -r : reuse C symbols value if possible (skips costly nm extraction). 
  11.   -s : silent mode, only echoes questions and essential information. 
  12.   -D : define symbol to have some value: 
  13.          -D symbol         symbol gets the value 'define' 
  14.          -D symbol=value   symbol gets the value 'value' 
  15.        common used examples (see INSTALL for more info): 
  16.          -Duse64bitint            use 64bit integers 
  17.          -Duse64bitall            use 64bit integers and pointers 
  18.          -Dusethreads             use thread support 
  19.          -Dinc_version_list=none  do not include older perl trees in @INC 
  20.          -DEBUGGING=none          DEBUGGING options 
  21.          -Dcc=gcc                 choose your compiler 
  22.          -Dprefix=/opt/perl5      choose your destination 
  23.   -E : stop at the end of questions, after having produced config.sh. 
  24.   -K : do not use unless you know what you are doing. 
  25.   -O : let -D and -U override definitions from loaded configuration file. 
  26.   -S : perform variable substitutions on all .SH files (can mix with -f) 
  27.   -U : undefine symbol: 
  28.          -U symbol    symbol gets the value 'undef' 
  29.          -U symbolsymbol=   symbol gets completely empty 
  30.        e.g.:  -Uversiononly 
  31.   -A : manipulate symbol after the platform specific hints have been applied: 
  32.          -A append:symbol=value   append value to symbol 
  33.          -A symbol=value          like append:, but with a separating space 
  34.          -A define:symbol=value   define symbol to have value 
  35.          -A clear:symbol          define symbol to be '' 
  36.          -A define:symbol         define symbol to be 'define' 
  37.          -A eval:symbol=value     define symbol to be eval of value 
  38.          -A prepend:symbol=value  prepend value to symbol 
  39.          -A undef:symbol          define symbol to be 'undef' 
  40.          -A undef:symbol=         define symbol to be '' 
  41.        e.g.:  -A prepend:libswanted='cl pthread ' 
  42.               -A ccflags=-DSOME_MACRO 
  43.   -V : print version number and exit (with a zero status). 

找到安装编译参数

 
  1. # ./Configure -des -Dprefix=/usr 
  2. 各参数的含义上面已有 
  3. # make && make install

如没有意外,安装成功,看看现在的版本

 
  1. # perl -v 
  2.  
  3. This is perl 5, version 14, subversion 1 (v5.14.1) built for x86_64-linux 
  4.  
  5. Copyright 1987-2011, Larry Wall 
  6.  
  7. Perl may be copied only under the terms of either the Artistic License or the 
  8. GNU General Public License, which may be found in the Perl 5 source kit. 
  9.  
  10. Complete documentation for Perl, including FAQ lists, should be found on 
  11. this system using "man perl" or "perldoc perl".  If you have access to the 
  12. Internet, point your browser at http://www.perl.org/, the Perl Home Page. 

看看安装的位置

 
  1. # ll /usr/bin/perl 
  2. -rwxr-xr-x 2 root root 1427485 Jul 13 14:06 /usr/bin/perl 

我们这是覆盖安装,替换了原先系统中的原始版本。

新的版本中增加了say函数,让我们写一个简单的脚本来测试一下,看有没有问题

 
  1. #!/usr/bin/perl -w 
  2.  
  3. use strict; 
  4. use 5.14.1; 
  5.  
  6. say "hello,world"; 

output:

 
  1. perl henry.pl  
  2. hello,world 

正确,大功告成,还不赶紧去了解Perl 5.14.1的新特性。哈哈,^__^

注:这样,似乎有一个问题,之前在Perl 5.8.8下安装过的模块需要重新再安装一下,嘿嘿



本文转自dongfang_09859 51CTO博客,原文链接:http://blog.51cto.com/hellosa/610052,如需转载请自行联系原作者

目录
打赏
0
0
0
0
69
分享
相关文章
|
11月前
|
Perl 教程 之 Perl 进程管理 5
Perl教程介绍了进程管理,包括使用$$或$PROCESS_ID获取PID,通过%ENV访问环境变量,exit()退出子进程。子进程继承打开的句柄,不受父进程影响。Perl的kill函数用于向进程发送信号,如SIGINT(值2)用于中断。示例展示了如何向进程104和102发送SIGINT信号。
77 0
|
11月前
|
Perl 教程 之 Perl 进程管理 7
在Perl中,可以通过$$或$PROCESS_ID获取进程ID,%ENV存储环境变量。exit()用于子进程退出,主进程等待所有子进程结束后才退出。打开的句柄在子进程中会被复制,不影响其他进程。POD是Perl内置的简单文档格式,以=head1开始,=cut结束。示例中展示了如何在代码中嵌入POD文档,并使用__END__或__DATA__注释后续内容。
72 1
|
11月前
|
Perl 教程 之 Perl 进程管理 3
Perl教程介绍了进程管理,包括获取进程ID、访问环境变量、退出进程及句柄影响。`fork()`函数创建新进程,返回子进程PID或在出错时返回`undef`。`exec()`在子进程中执行命令后结束。示例代码演示了`fork()`和`exec()`配合使用,展示父进程和子进程的不同输出。
68 1
|
11月前
|
Perl 教程 之 Perl 进程管理 4
Perl教程介绍了进程管理,包括使用$$或$PROCESS_ID获取PID,%ENV存储环境变量,exit()退出子进程,fork()创建新进程。在父进程返回子进程PID,在子进程返回0。fork与exec配合执行命令。示例展示了父进程如何等待子进程结束。当子进程变为僵死状态时,父进程需使用wait或waitpid终止,或设置$SIG{CHLD}为"IGNORE"。
83 1
|
11月前
|
Perl 教程 之 Perl 进程管理 6
Perl教程介绍了进程管理,包括通过$$或$PROCESS_ID获取PID,使用%ENV访问环境变量,exit()用于子进程退出。子进程继承打开的句柄,不影响父进程。此外,POD文档在Perl中用于嵌入简单文档,以=head1开始,=cut结束,Perl会忽略这些文档。示例展示了在脚本中添加POD文档的基本结构。
48 0
|
11月前
|
Perl 教程 之 Perl 进程管理 2
Perl教程介绍了进程管理,包括获取进程ID、访问环境变量 `%ENV`、使用`exit()`退出子进程以及`system()`函数执行Unix命令。`system()`函数的输出默认发送到STDOUT,可以通过重定向运算符>`输出到文件。示例展示了`system()`如何处理环境变量,如 `$PATH`,在不同引用方式下的不同结果。
48 0
|
11月前
|
Perl 教程 之 Perl 进程管理 1
Perl教程介绍了进程管理,包括通过$$或$PROCESS_ID获取PID,使用%ENV访问环境变量,exit()退出子进程。子进程继承打开的句柄,反引号运算符用于执行Unix命令并捕获输出。示例代码展示了用反引号列出目录内容并逐行打印。
70 0
升级openssh版本
有网络情况下 1 下载包,编译 tar zxvf openssh-7.1p1.tar.gz cd openssh-7.1 ./configure --prefix=/usr --sysconfdir=/etc/ssh make make install 2 解决如下环境报错:    configure: error: *** zlib.
1592 0
如何安装perl模块
由于生物信息早期最多用的语言是perl,因此不可避免就要用别人的perl脚本或者基于perl的项目来处理数据。 使用perl脚本和使用其他编程语言的脚本没啥不同,毕竟你只要传入参数,它就能给你结果。
3269 0