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 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:
print("Hi, this is test script Hello world\n");
ii. 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
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.