Categories: Ubuntu

How 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.In this article, we will talk about the best steps to install Perl language and how we can create and run the Perl script through the command line on Ubuntu 20.04.

Prerequisites

Sponsored

You should have sudo access to run administrative commands on your system.

Installation of Perl on Ubuntu 20.04

We have implemented different steps in this article on the command line application ‘Terminal’. Before going to start the Perl installation steps in detail, open the terminal window. You can access this application by pressing ‘Ctrl+Alt+t’ or you can also open it from the application menu.

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

Step 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.

Step 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.

Step 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 which you can see in the following snapshot:

Step 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:

Sponsored
$ perl -v

As you can see in the below-given screenshot that Perl version ‘v5.30.0.’ is installed our system.

Step 5: Run Your First Perl Script on Ubuntu 20.04

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:

#!/usr/bin/perl

use warnings;

print(“Hi, this is test script Hello worldn);

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

$ perl helloworld.pl

The following result will be shown on the terminal after running the above mentioned script:

Step 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.

Conclusion

In the above article, we have explained the installation of 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. Please let us know about your difficulties or queries related this article.

Ubuntu Server Admin

Recent Posts

Building RAG with enterprise open source AI infrastructure

One of the most critical gaps in traditional Large Language Models (LLMs) is that they…

1 hour ago

Life at Canonical: Victoria Antipova’s perspective as a new joiner in Product Marketing

Canonical is continuously hiring new talent. Being a remote- first company, Canonical’s new joiners receive…

1 day ago

What is patching automation?

What is patching automation? With increasing numbers of vulnerabilities, there is a growing risk of…

2 days ago

A beginner’s tutorial for your first Machine Learning project using Charmed Kubeflow

Wouldn’t it be wonderful to wake up one day with a desire to explore AI…

3 days ago

Ubuntu brings comprehensive support to Azure Cobalt 100 VMs

Ubuntu and Ubuntu Pro supports Microsoft’s Azure Cobalt 100 Virtual Machines (VMs), powered by their…

3 days ago

Ubuntu Weekly Newsletter Issue 870

Welcome to the Ubuntu Weekly Newsletter, Issue 870 for the week of December 8 –…

4 days ago