Category: Ubuntu

Added: 17th of December 2015

Updated On: 3rd of October 2020

Viewed: 4910 times

Install Perl in Ubuntu, and create a perl script

This article was rechecked and updated on 03/10/20
This tutorial works in Ubunbu, Kubuntu, Xubuntu, Lubuntu, Ubuntu Mate and other Ubuntu based distributions. The tutorial also works in Linux Mint and other Debian based distributions.

The simple script below prints the message My First Perl Script in the terminal using perl.
Perl may be an old language but once you start learning it, there is so much more you can do with it over PHP.

Is Perl still worth learning in 2015?
If Perl provides you with the functions you need, then it is definitely worth learning.

To start using perl in Ubuntu you first need to install perl.
Run the following command in your terminal. You will be required to enter your password.

sudo apt-get install perl

Then enter the following command in the terminal. This will show the path to perl
which perl

It will show that your path to perl is usr/bin/perl
You will enter this path at the top of every perl script you create. It tells the system where to find perl.

To create your first perl script copy and paste the code below in to a text file and save it as
#!/usr/bin/perl -w
print"My First Perl Script\n";

The next thing to do is make the perl script executable.
To do this, CD to the directory of where your perl script is located, and enter the following command in the terminal
chmod +x

We now need to run the script. Enter the following command in the terminal.

If everything works correctly the following will be output in the terminal.
My First Perl Script

Congratulations, you have just created your first perl script.

Other Tips & Tutorials


How do I upgrade a single package in Ubuntu and Ubuntu based distributions

Posted: 12th of September 2021

Views: 248


Create a multiboot USB for your .iso images, using Ventoy on Linux

Posted: 25th of August 2021

Views: 341


How to find out what date you installed Linux on your machine

Posted: 13th of April 2021

Views: 476


Install bashtop in Ubuntu and Ubuntu based distributions. Monitor your cpu, memory, disks, network and other processes

Posted: 21st of February 2021

Views: 587


Ubuntu 20.10 Groovy Gorilla installation error, installer crashed

Posted: 3rd of February 2021

Views: 973


Find out what version of Ubuntu you are running, using the terminal

Posted: 29th of January 2021

Views: 483


Install Redshift to automatically adjust the colour of your screen depending on time of day on Ubuntu and Ubuntu based distributions

Posted: 26th of November 2020

Views: 1079


PulseAudio, Pavucontrol not saving settings after reboot on Ubuntu and Ubuntu based distributions

Posted: 11th of November 2020

Views: 3753


No sound after installation of Ubuntu or Ubuntu based distribution, install pavucontrol

Posted: 9th of November 2020

Views: 585


Shutdown Ubuntu and Ubuntu based distributions at a specific time or within (x) minutes

Posted: 30th of October 2020

Views: 671