2

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.

ash14
  • 23
  • 3
  • 1
    Should you not be using Ubuntu's own software upgrade features? And use the root user when updating. Ubuntu related questions are best asked at SE's ubuntu site, askubuntu.com. I found this one: https://askubuntu.com/questions/196768/how-to-install-updates-via-command-line – TLP Jun 25 '22 at 10:31
  • 5
    You've used `... -Dprefix=$HOME/localperl` so you need to also set your path accordingly, i.e. `export PATH=$HOME/localperl/bin/:$PATH` – Steffen Ullrich Jun 25 '22 at 10:48
  • @TLP From what I've understood from reading on other questions on se, each Ubuntu version has a perl version associated with it and has dependencies on it (I don't know what that means) and it cannot be updated. A new perl version has to be installed if one needs to use it. Correct me if what I've understood is wrong, but this is my little understanding of something I am very new to. – ash14 Jun 27 '22 at 05:25

1 Answers1

4
-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
ikegami
  • 367,544
  • 15
  • 269
  • 518