Perl is a programming language that is used in the development of many applications for the last thirty years and is used for rapid prototyping of large-scale development projects. If we talk about some of the notable features of the Perl programming language then it contains more than 25000 open source modules, it also supports Unicode version 3, and can be interfaced with third-party Databases like MySQL.
Perl can be compiled and run on different platforms but in this guide, we will explore the creation and running of Perl script on Ubuntu 22.04.
How to create and run a Perl Script on Ubuntu 22.04
Before creating the script for the Perl programming language, we have to install the package Perl which is available in the default repository of Ubuntu and can check by using the command:
$ sudo apt show perl
We can install Perl using the apt package manager:
$ sudo apt install perl -y
To confirm the installation of Perl, we will check the version of installed Perl by running the command:
$ perl --version
To create a script of Perl, we will make a file with the name of “mycode” with the extension of “.pl” and open it with a nano text editor:
$ nano mycode.pl
Copy and paste the Perl script which is shown below to display a note “Welcome to Linux”:
#!/usr/bin/perl use warnings; print("Welcome to Linux\n");
Exit the nano editor by saving the file and run the Perl script by using the command:
$ perl mycode.pl
If you want to interface the MySQL with Perl, then you have to install the SQL modules by executing the command:
$ sudo apt install libdbd-mysql-perl -y
Perl is a high level and general-purpose language that was initially launched for text manipulation but now it is being used for multi-purpose development projects. In this write-up, a simple script of Perl has been created and run on Ubuntu to understand the usage of Perl on Ubuntu 22.04.
TUTORIALS ON LINUX, PROGRAMMING & TECHNOLOGY