How to install Perl on Ubuntu 22.04

Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"

Hello, friends. In this post, you will learn how to install Perl on Ubuntu 22.04.

What is Perl?

On the language’s website, you will find this definition:

Perl is a highly capable, feature-rich programming language with over 30 years of development.

Yes, despite having 30 years of service, Perl is still making its mark in backend applications and complex configuration scripts. So don’t be surprised that it’s still so popular.

Perl has been modernized and includes a Python-style package manager called CPAN. It also has a fairly large user community, which means that there is documentation everywhere.

On top of this, it is highly flexible, so you can use it for almost any purpose while being fast and secure.

Install Perl on Ubuntu 22.04

The best and fastest way to get Perl on Ubuntu 22.04 is to do it via the distribution’s official repositories. This provides us with a stable and well-integrated version of the system.

So, open a terminal or via SSH connect to the computer. Then, update the whole system completely:

sudo apt update
sudo apt upgrade

Then, as Perl is in the Ubuntu repositories, you just need to run the following command:

sudo apt install perl

In this way, not only the language as such and its interpreter will be installed, but also certain modules that are important for its operation.

At the end of the process, you only have to execute this command to verify the version installed

perl -v

You will get an output like this:

This is perl 5, version 34, subversion 0 (v5.34.0) built for x86_64-linux-gnu-thread-multi
(with 50 registered patches, see perl -V for more detail)

Copyright 1987-2021, 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.

Test Perl on Ubuntu 22.04

The best way to know if Perl works is to create a file and run it.

So, create a file with extension .pl.

nano hello.pl

And add some code like this

#!/usr/bin/perl
use warnings;
print("Hi, welcome to unixcop\n");
Using Perl on Ubuntu 22.04
Using Perl on Ubuntu 22.04

Save the changes and close the editor.

Now run it with the following command

perl hello.pl

And you should see the output on the screen

Hi, welcome to unixcop

Conclusion

Today you learned about Perl and how to install it on a modern system like Ubuntu 22.04. This is a great step to learn about this language and the possibilities it gives.

Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"
Angelo
Angelo
I am Angelo. A systems engineer passionate about Linux and all open-source software. Although here I'm just another member of the family.

1 COMMENT

  1. Thanks for the info, Angelo. I have just recently updated to 22.04 (6 October 2022) and am still installing necessary packages and libraries. I was installing Gdebi today and one of the recommended packages is `libgtk2-perl` however when I try to install it I get an error saying “Package ‘libgtk2-perl’ has no installation candidate”. It says this library is “not available, but is referred to by another package”. I was just curious if you knew what may be causing this error. I have perl 5.34.0 and libglib-perl 3:1.329.3-2build1 installed, which Ubuntu tells me are the most up-to-date versions.

    Thanks for the help!

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest articles

Join us on Facebook