Buy best selling Linux books

<< View More Computer Tips

Added On: 17/12/15   |    Category: Ubuntu    |    Number of Views: 2137

Install Perl in Ubuntu, and create a perl script   

Note: This tutorial will also work in Kubuntu, Lubuntu, Xubuntu, Ubuntu Gnome, Ubuntu Mate, Linux Mint and other Ubuntu 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.

Search Site

Search other tutorials and tips on My Computer Tips by entering your search terms below


The Linux Foundation

Best selling Unix / Linux books
Nvidia Graphics Cards
Save 15% off .CO.UK domains at 123-Reg
Save 15% off .COM domains at 123-Reg
cPanel Hosting Plans
Xilo Web Hosting Plans