Bootstrap FreeKB - Perl (Scripting) - Install Perl on Linux
Perl (Scripting) - Install Perl on Linux

Updated:   |  Perl (Scripting) articles

The easiest way to install Perl is to use apt-get or yum.

~]# apt-get install perl
~]# yum install perl

 

If for some reason apt-get or yum cannot be used, install gcc.

~]# yum install gcc

 

If curl is not installed, install curl.

~]# yum install curl

 

Issue the following command to install Perl.

~]# curl -k -L http://xrl.us/installperlnix | bash

 

Ensure Perl was installed.

~]# perl -v
This is Perl 5 . . .

 

If these "easy" options fail for whatever reason, you can also try to build Perl from source. For example, you can use wget to download the Perl source code tarball.

wget https://www.cpan.org/src/5.0/perl-5.38.2.tar.gz

 

Extract the tar archive.

tar -zxpf perl-5.38.2.tar.gz --directory /tmp

 

You can now remove the tar archive.

rm perl-5.38.2.tar.gz

 

Move into the extracted directory.

cd /tmp/perl-5.38.2

 

And then run the Configure script. The -Dprefix option is used to specify the directory where Perl will be installed. This command will not create /usr/local/bin or install Perl in the /usr/local/bin directory. Instead, when the make install command is issued, Perl will be installed in the /usr/local/bin directory.

./Configure -des -Dprefix=/usr/local/bin/perl5.38.2

 

And then run the make command. You want this command to return build finished successfully!.

make

 

And then run the make test command. This is just to let you know if the next command (make install) should be successful.

make test

 

And last but not least, make install.

sudo make install

 

It's fairly common for the perl command to be symbolically linked to /usr/local/bin/perl.

~]# ls -l | grep /usr/local/bin/perl
lrwxrwxrwx. 1 root root 7 Mar  7 23:31 /usr/local/bin/perl -> perl

 

In other words, the "perl" command points to what version of Perl /usr/local/bin/perl is.

~]# perl --version
This is perl 5, version 16, subversion 3 (v5.16.3) built for x86_64-linux-thread-multi
(with 44 registered patches, see perl -V for more detail)

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.

 

You may want to instead have the "perl" command symbolically linked to the version of Perl that you just installed from source. To do this, first use the unlink command to remove the symbolic link between the "perl" command and /usr/local/bin/perl.

unlink perl /usr/local/bin/perl

 

And then create a symbolic link from /usr/local/bin/perl<version>/bin/perl to perl.

 

ln -s perl /usr/local/bin/perl5.38.2/bin/perl

 

Now the /usr/local/bin directory should contain a symbolic link from perl to /usr/local/bin/perl<version>/bin/perl

]# ll /usr/local/bin/ | grep -i perl
lrwxrwxrwx.   1 root root          40 Oct 31 07:14 perl -> /usr/local/bin/perl5.38.2/bin/perl

 

And the perl command can be used to see that Perl version 5.38.2 is indeed being used.

~]# perl --version

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter cc1968 in the box below so that we can be sure you are a human.