Debian

How to Install Perl Modules on Debian Linux?

Perl is a very popular high-level programming language. It is a scripting language, in fact, whose syntax resembles closely with C and C++. A Perl module is defined as a collection of related functions. It is very much similar to the concept of libraries is C++ and Java. This means that if you intend to run a function in Perl, you must have the respective module for that function installed on your system. That is why in this article, we will be learning the method of installing Perl modules on Debian 10.

Method of Installing Perl Modules on Debian Linux:

For installing Perl modules on Debian 10, you will have to go through all the steps listed below:

Step # 1: Installing Perl on Debian 10:

First of all, you need to have Perl installed on your Debian 10 system. For that, you will launch the terminal in Debian 10 by looking for it in the Activities menu. The Debian 10 terminal can be seen in the following image:

Now you have to run the following command in your terminal to install Perl on your Debian 10 system:

sudo apt-get install Perl

Once the installation of Perl completes successfully, the output shown in the image below will be displayed on your Debian 10 terminal:

Step # 2: Updating System Cache:

Before installing Perl modules, you are advised to update your system’s cache with the following command:

sudo apt-get update

Once all the required packages and dependencies have been updated, you will be able to witness the following output on your Debian 10 terminal:

Step # 3: Installing CPAN on Debian 10:

The best way of installing Perl modules on Debian 10 is via the CPAN repository. For doing so, we first need to install this repository on our Debian 10 system, which can be done with the below-mentioned command:

sudo apt-get install libpath-tiny-Perl

During the installation of the CPAN repository, you need to type “Y” in your terminal for carrying on with its execution as highlighted in the following image:

Once the CPAN repository has been successfully installed on your Debian 10 system, the terminal will produce the output shown in the image below:

Step # 4: Launching and Configuring the CPAN Interactive Shell:

For installing Perl modules with CPAN, you first need to launch and configure the CPAN interactive shell, which can be done simply by running the following command in your terminal:

cpan

As soon as you try to launch the CPAN interactive shell with the above-mentioned command, you will be asked to configure it. You have to type in “yes” and then press the Enter key as highlighted in the image shown below:

After doing this, you will be asked to choose an approach with which you want to install your modules. The approach chosen by default is “[local: lib],” and it is also the recommended approach. Therefore, for selecting this approach, you simply need to press the Enter key, as shown in the following image:

It will take a few seconds for the automatic configuration process of CPAN to complete, after which the CPAN interactive shell will appear on your screen as shown in the image below:

Step # 5: Installing Perl Modules via CPAN on Debian 10:

Now you can visit the following site: http://www.cpan.org/modules/index.html to look for any module of your choice that you want to install. After choosing a module to install, you are supposed to run the following command in your CPAN interactive shell:

install ModuleName

Here, you have to replace ModuleName with the name of the specific module that you want to install via CPAN on your Debian 10 system. For the sake of demonstration, we will be installing the MIME: Lite module, as shown in the image below:

Once the desired module has been installed on your Debian 10 system, your CPAN interactive shell will look something like shown in the following image. In the same manner, you can also install any other Perl module of your choice. Once you are done with the installation, and you want to go back to your regular terminal, you can simply type the “exit” command followed by pressing the Enter key to switch from your CPAN interactive shell to your Debian 10 terminal as shown in the following image:

Conclusion:

By using the simple method described in this article, one can easily install as many Perl modules as he wants or according to his requirements. In this way, you will be all set to create Perl scripts from very basic to extremely complex.

About the author

Karim Buzdar

Karim Buzdar

Karim Buzdar holds a degree in telecommunication engineering and holds several sysadmin certifications. As an IT engineer and technical author, he writes for various web sites. He blogs at LinuxWays.