Home > Blockchain >  If there are two perl versions installled on Ubuntu18.04, how can I make the new perl version my def
If there are two perl versions installled on Ubuntu18.04, how can I make the new perl version my def

Time:06-27

The default perl version installed on my machine is 5.26.1. I found this out by using the following command:

perl -v
 
This is perl 5, version 26, subversion 1 (v5.26.1) built for x86_64-linux-gnu-thread-multi
(with 71 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.

I installed the newest perl version from source using the following commands present on the link (https://www.cpan.org/src/):

 wget https://www.cpan.org/src/5.0/perl-5.36.0.tar.gz
 tar -xzf perl-5.36.0.tar.gz
 cd perl-5.36.0
 ./Configure -des -Dprefix=$HOME/localperl
 make
 make test
 make install

I tried changing the path to /usr/local/bin/ using the following command but it didn't work:

 export PATH=$HOME/usr/local/bin/:$PATH

On checking the perl version using perl -v, I am still getting perl 5.26.0 as the installed version.

How can I make perl 5.36.0 as my default version?

I am new to Linux. Any help is appreciated.

CodePudding user response:

-Dprefix="$HOME/localperl"

means that perl is located at $HOME/localperl/bin/perl. You can verify this using

"$HOME/localperl/bin/perl" -v

As such, the correct PATH addition is $HOME/localperl/bin.

export PATH="$HOME/localperl/bin:$PATH"

You might want to consider perlbrew. It's a tool that can be used to install different versions of perl, and to manipulate the PATH to switch between them.

You already know how to do the former, but perlbrew also applies patches to older versions of Perl to fix problems that prevent them from being installed.

But it seems you might get benefit from the latter.

$ perl -v | grep 'This is'
This is perl 5, version 36, subversion 0 (v5.36.0) built for x86_64-linux-thread-multi

$ perlbrew use 5.34t

$ perl -v | grep 'This is'
This is perl 5, version 34, subversion 0 (v5.34.0) built for x86_64-linux-thread-multi
  • Related