How to install Perl programming in Fedora Linux?


Perl is a general-purpose, high-level, interpreted programming language. It is the acronym of Practical Extraction and Reporting Language, initially, Perl was designed as a scripting language to make report processing easier.

Perl is used in web development for writing server-side tasks and interfacing the front end to the database. It was developed by Larry Wall in 1987.

Today in this article I will discuss how to install Perl programming in Fedora Linux.

Prerequisites

To set up Perl programming in a Fedora system you should have the following –

  • A system running on a recent version of Fedora Linux
  • Access to a user account that has sudo privileges

How to install Perl in Fedora

Perl is available in the default package repository of Fedora Linux so it can be directly installed using the dnf command in the terminal.

But before installing a package make sure your system is updated –

sudo dnf update -y

Next, use the given command to install Perl on your system –

sudo dnf install perl

Press y and then enter if it asks for your confirmation.

You can verify Perl installation by checking its version –

perl -v

perl version

Write your first Perl script in Fedora

You have set up Perl on your system now you can write your first script in Perl. Here we will see the example of the hello world program.

Use the following command to create a Perl file (with .pl extension) –

nano hello.pl

Here we are using the nano text editor you can use any other editor for writing your code.

Add the following code to this file.

#!/usr/bin/perl
use warnings;
print("Hello, World!\n");

Save the file by pressing ctrl+s and exit from the editor by using ctrl+x.

Now execute this script by using the given command.

perl hello.pl

You can see the output of this script in the image below.

perl hello.pl output

How to install a Perl module in Fedora

Perl module is a collection of related subroutines and variables that can perform a set of programming tasks. This increases the reusability of Perl code.

You can use CPAN (Comprehensive Perl Archive Network) which features a wide range of Perl modules to install these modules. Perl provides cpan shell for installing or removing Perl modules in a system.

You can search for a Perl module here.

The following command will download the module for MySQL driver for the Perl5 Database Interface (DBI).

sudo cpan DBD::mysql

Conclusion

So you have successfully installed Perl programming on your Fedora system.

Now if you have a query related to this you can write us in the comments below.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.