Steps to create and run a Perl script in Ubuntu 20.04 LTS ?

Perl is abbreviated for Practical Extraction and Reporting Language that is a well-known and powerful language for String Processing and handling. It is a web scripting language that can be used along with different web frameworks and the latest technologies. 

Mostly the Perl used for server-side scripting but, it can also be used to front-end interface programming languages like HTML with the backend in the Database application. 

It is fast and robust so, it can interact with many other programming languages on different platforms.

Here at LinuxAPT, as part of our Server Management Services, we regularly help our Customers to perform Linux related queries.

In this context, we shall look into steps to install Perl language and how we can create and run the Perl script through the command line on Ubuntu 20.04.

Steps to Install Perl on Ubuntu 20.04 ?

To install Perl on your Server, you need to have sudo priviledge or log into your Server as the root user.

You can use an SSH tool or Terminal application to log into the server.

Open the terminal window. You can access this application by pressing 'Ctrl+Alt+t' or you can also open it from the application menu.

Then, Execute the following different steps to install Perl and run a Perl script on your Ubuntu system:

1. Update your system

Before going to start the installation of Perl, it is recommended to update your system by typing the following command via terminal:

$ sudo apt update

The above command will download and install all available updates for your Ubuntu 20.04 apt repository.

2. Install Perl on Ubuntu 20.04

On our system, Perl is already installed. But, if you don't have Perl installed on your system then, you can install it directly from the Ubuntu repository by typing the following command:

$ sudo apt install perl

The above command will automatically install the all required Perl packages and dependencies on your system.

3. Verify the Perl Installation

Once the installation of Perl is completed, now you can verify the installation by using the following ‘grep’ command on your terminal:

$ apt list --installed | grep -i perl

The above command will find the all installed packages of Perl and list on the terminal window.

4. Check Installed Perl Version

If you want to know which Perl version is installed on your Ubuntu system then, by executing the following command you can check it:

$ perl -v

This command will show you the version of Perl Installed on the system.

5. Run Your First Perl Script on Ubuntu 20.04

i. Now, it’s time to run your first Perl script on your system. To do this, create a simple text file in your favorite text editor and paste the following code into it:

use warnings;
print("Hi, this is test script Hello world\n");

ii. Save the above file with named ‘’. The file will be saved in your home directory by default. Run this file via the terminal by typing the below-mentioned command:

$ perl

Now the contents will be displayed.

6. Install Perl Sql module on Ubuntu 20.04

You can install the MySQL module for Perl on your Ubuntu 20.04 system. 

To do this, follow the below apt command to install the Perl Mysql module:

$ sudo apt install libdbd-mysql-perl -y

The above mentioned command will install the necessary mysql Perl packages on your Ubuntu system.

[Need urgent assistance with Packages installation on your Ubuntu Server? We are available to help you. ]

This article will guide you on steps to #install Perl and how to create and run Perl #script using the command line on #Ubuntu 20.04. We have also discussed how to configure necessary #Perl #modules on your system.

Perl is a programming language that can be used to perform tasks that would be difficult or cumbersome on the command line. Perl is included by default with most GNU / #Linux #distributions. Usually, one invokes Perl by using a text editor to write a file and then passing it to the perl #program.

Perl has a wide range of command-line options or switches that you can use. The options are also called switches because they can turn on or turn off different behaviors. For example, the -e option lets you specify a line of code directly on the command line instead of creating a script file.

To install Perl in Linux:

1. SSH to your server.

2. Change your directory to /opt by running the below command. cd /opt.

3. Download the zipped source code available for Unix/Linux.

4. After download the zip file runs the below commands to extract and install Perl.

Related Posts