the default Perl version installed on my machine is the 5.8.7. When I run my script internally switch to another perl version (v5.10.1) doing this:
my $perl_5_10 = "/opt/perl_5.10.1/bin"; $ENV = $perl_5_10 ":" . $ENV;
## PERL: need perl version >= 5.10! if ($] < 5.010000) < ## VERSION ERROR! >my $perl_cmd = "perl --version"; my $perl_str=`$perl_cmd`; print "PERL VERSION mt24 mb12">
perlversion
)" data-controller="se-share-sheet" data-se-share-sheet-title="Share a link to this question" data-se-share-sheet-subtitle="" data-se-share-sheet-post-type="question" data-se-share-sheet-social="facebook twitter devto" data-se-share-sheet-location="1" data-se-share-sheet-license-url="https%3a%2f%2fcreativecommons.org%2flicenses%2fby-sa%2f3.0%2f" data-se-share-sheet-license-name="CC BY-SA 3.0" data-s-popover-placement="bottom-start">Share
Put use 5.010001 into the script that needs to run in the newer version.
– choroba
May 8, 2014 at 20:45
1
The main script I know will start with the version 5.8 but after being launched I switch to 5.10. At thet point I have to check if I switched correctly (or the new version is available) .
– Kasper
May 8, 2014 at 20:52
What does it mean to switch?
– mpapec
May 8, 2014 at 20:57
1
That my script is launched with a perl version, then I add to the env variable another perl version (see code) 5.10 and then from this script I run another script. But first need to check that the new perl version is available . That's all
– Kasper
May 8, 2014 at 21:23
|Show 2 more comments
2 Answers 2
Reset to default
7
The first 3 decimals are the subversion, and second 3 decimals are revision. Therefore use
if ($] >= 5.010001)
I primarily use 5.18.2, and therefore my $] equals 5.018002 . For alternative methods check out perlvar $PERL_VERSION or $^V and use VERSION
Буду описывать здесь процесс выполнения различных работ.
Страницы
html
суббота, 12 октября 2013 г.
Perl. Определяем версию Perl
1.Чтобы найти версию Perl, необходимо в терминале набрать следующую команду: perl – v Если необходима развернутая информация, то команда немного иная: perl – V.
Выполнение команды perl -v для определения версии
2. Напишем sh-скрипт для определения версии Perl. Текст скрипта : --------------------------------------------- #!/bin/sh # # Скрипт для проверки версии Perl на машине # cd /usr/bin ; echo "---------------------- Version perl. command: perl -V --------------" perl -V; echo "---------------------- Version perl. command: perl -v --------------" perl -v; echo "--------------------------------------------------------------------" echo "Press Enter key for exit" read Enter_key ; ---------------------------------------------
Код sh-скрипта для определения версии perl
3.Сделаем скрипт исполняемым , как рассказано в посте Perl. Первая программа "Hello world !" и запустим. Получим следующее:
Вывод скрипта для определения версии Perl в терминал
4 Полезные ссылки : -- HowTo Find Out Perl Version -- forum.opennet.ru - "Как определить, какая версия perl модуля установлена?"
Get detailed Perl version configuration information
Most Perl programmers know they can find out the current Perl version by typing “perl -v” as the command line:
perl -v This is perl 5, version 16, subversion 3 (v5.16.3) built for x86_64-linux Copyright 1987-2012, Larry Wall Perl may be copied only under the terms of either the Artistic License or the GNU General Public License, which may be found in the Perl 5 source kit. Complete documentation for Perl, including FAQ lists, should be found on this system using "man perl"or"perldoc perl". If you have access to the Internet, point your browser at http://www.perl.org/, the Perl Home Page.
To get detailed version information type “perl -V” (capital V) at the command line:
This prints detailed information on the installed Perl’s configuration including: the options that Perl was compiled with, whether iThreads are enabled or not and a host of directory information.
This article was originally posted on PerlTricks.com.
Perl Tutorials - Herong's Tutorial Examples - v6.01, by Dr. Herong Yang
∟ Perl Installation on Linux Systems
This section describes how to verify Perl installation on Linux systems. The 'perl -v' command returns which version of Perl is installed on the Linux system.
If you are running a Linux system, Perl is already installed on the system. No need to do any extra installation work.
Here is what I did to verify the Perl installation on the Linux server of my Internet service provider in 2019:
/home/herong$ which perl /usr/bin/perl /home/herong$ perl -v This is perl 5, version 26, subversion 1 (v5.26.1) built for x86_64-linux-gnu-thread-multi (with 67 registered patches, see perl -V for more detail) Copyright 1987-2017, Larry Wall Perl may be copied only under the terms of either the Artistic License or the GNU General Public License, which may be found in the Perl 5 source kit. Complete documentation for Perl, including FAQ lists, should be found on this system using "man perl" or "perldoc perl". If you have access to the Internet, point your browser at http://www.perl.org/, the Perl Home Page. /home/herong$ man perl PERL(1) Perl Programmers Reference Guide PERL(1) NAME perl - The Perl 5 language interpreter SYNOPSIS perl [ -sTtuUWX ] [ -hv ] [ -V[:configvar] ] [ -cw ] [ -d[t][:debugger] ] [ -D[number/list] ] [ -pna ] [ -Fpattern ] [ -l[octal] ] [ -0[octal/hexadecimal] ] [ -Idir ] [ -m[-]module ] [ -M[-]'module. ' ] [ -f ] [ -C [number/list] ] [ -S ] [ -x[dir] ] [ -i[extension] ] [ [-e|-E] 'command' ] [ -- ] [ programfile ] [ argument ]. For more information on these options, you can run "perldoc perlrun". GETTING HELP The perldoc program gives you access to all the documentation that comes with Perl. You can get more documentation, tutorials and community support online at . .
As you can see from the output, this Linux system has Perl 5.26.1 installed and ready to use.
Even on older versions of Linux systems, Perl was included in Linux distribution packages and installed automatically. Here is an example captured on the Linux server of my Internet service provider in 2009
/home/herong$ which perl /usr/local/bin/perl /home/herong$ perl -v This is perl, v5.8.8 built for i486-linux-gnu-thread-multi Copyright 1987-2006, Larry Wall .
Here is another example captured on my old PC running a Linux 2.0.30 system in 1999:
/home/herong$ which perl /usr/bin/perl /home/herong$ perl -v This is perl, version 5.004_03 Copyright 1987-1997, Larry Wall .