Installing a custom version of Perl locally

Overview

You can install a custom version of Perl locally under your username over SSH — download the source from CPAN, then configure, make, and install it, and point your .bash_profile to the new version. The default Perl on Ubuntu 18 (Bionic) servers is 5.26.

It's highly recommended that you only use a version of Perl which is currently maintained. This means you should not use a version that has been End-of-Life'd. You can view a full list of versions and their status here:

How do I install a custom version of Perl?

  1. Log into your server via SSH.

  2. Visit https://www.cpan.org/src/ to download your version of Perl. Run the wget command to download the tar.gz file.

    [server]$ wget https://www.cpan.org/src/5.0/perl-5.18.4.tar.gz
  3. Decompress this file.

    [server]$ tar zxf perl-5.18.4.tar.gz
  4. Change into the new directory.

    [server]$ cd perl-5.18.4
  5. Run the configure command for the directory you wish to install into. This example installs into a directory named /opt/perl under your username.

    [server]$ ./Configure -des -Dprefix=$HOME/opt/perl
  6. Run make, make test, and finally make install.

    [server]$ make
    [server]$ make test
    [server]$ make install
  7. Add code to your .bash_profile to find the local version.

    export PATH=$HOME/opt/perl/bin:$PATH
  8. source the .bash_profile.

    [server]$ . ~/.bash_profile
  9. Check to confirm the new version is being used.

    [server]$ perl -v
    This is perl 5, version 18, subversion 4 (v5.18.4) built for x86_64-linux

See also

This form is only for article feedback. If you require assistance, please contact support. Do not include passwords, account numbers, or other private account details.

Did this article answer your questions?

Article last updated PST.

Still not finding what you're looking for?