Category: Ubuntu

Added: 17th of December 2015

Updated On: 3rd of October 2020

Viewed: 3155 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 perl.pl
#!/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 perl.pl


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


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

Ubuntu

Download Microsoft Edge preview version for Ubuntu and Ubuntu based distributions

Posted: 22nd of October 2020

Views: 43

Ubuntu

Create a really simple banner using GIMP (GNU Image Manipulation Program) in Linux

Posted: 7th of August 2020

Views: 166

Ubuntu

Install the tree package to list folders and files in a tree like format inside the terminal on Linux

Posted: 22nd of July 2020

Views: 167

Ubuntu

Ubuntu 4.10, Warty Warthog. The first Ubuntu Linux Distribution

Posted: 6th of October 2019

Views: 962

Ubuntu

Sim City 4 Deluxe Edition Install Wine Linux. Trouble installing from CD/Disk 2

Posted: 19th of May 2019

Views: 1228

Ubuntu

Where are the fonts located in Ubuntu and other Ubuntu based distributions

Posted: 3rd of June 2018

Views: 1335

Ubuntu

Install MariaDB Database in Ubuntu and other Ubuntu based distributions (Part 1)

Posted: 26th of May 2018

Views: 1274

Ubuntu

Convert .mkv video to .png images using ffmpeg

Posted: 24th of May 2018

Views: 2623

Ubuntu

Shutdown Ubuntu using the terminal

Posted: 20th of May 2018

Views: 1142

Ubuntu

Running Sketchup 8 in Wine. Sketchup was unable to initialize OpenGL, Linux

Posted: 29th of May 2016

Views: 3576