- How To Install Perl Modules On Linux
- Install Perl Modules On Linux
- Install Perl modules using cpan
- Install Perl modules using Cpanminus
- Install missing Perl modules using distribution’s package manager
- List installed Perl modules
- Uninstall Perl modules
- Help us to help you:
- Perl Download
- Unix/Linux
- macOS
- Windows
- Unix
- Binaries
- Source
- Mac OS X
- Binaries
- Source
- Windows
- Binaries
- Source
- How to Install Perl on Linux?
- Checking for a preinstalled Perl version:
- Downloading and Installing Perl:
How To Install Perl Modules On Linux
This brief guide explains how to install Perl modules on Linux from CPAN (Comprehensive Perl Archive Network) repository. As of writing this guide, there are 185,128 Perl modules available in CPAN. Many programs written in Perl programming language depends on certain perl modules to perform a specific task. For example, the other day I was testing Sysadmin-util which provides a collection of useful tools for Linux/Unix sysadmins. When I test a specific tool called multi-ping, I encountered with the following error:
$ ./multi-ping google.com The required Net::DNS module is missing. Aborting.
In such cases, you need to find and install the missing perl module in order to use that program.
Install Perl Modules On Linux
There are many tools available to install and Perl modules. We are going to try two tools namely cpan and cpanm. It is worth mentioning that Many modules on CPAN requires the recent version of Perl version 5.8 or above.
Please ensure that you have installed ‘make’ package on your Linux distribution. ‘make’ is an essential tool for building perl Modules.
If you don’t install ‘make’, you might encountered with an error something like below:
Can't configure the distribution. You probably need to have 'make'.
‘make’ package is available in the default repositories most Linux distributions.
To install ‘make’ on Arch Linux and its variants, run:
On Debian, Ubuntu, Linux Mint:
On RHEL, CentOS:
On SUSE/openSUSE:
Let us go ahead and install perl modules.
Install Perl modules using cpan
cpan is a command line client for CPAN repository and is distributed with all Perl editions by default.
To install a Perl module, for example Net::DNS, enter into cpan shell using command:
And type the following command from cpan prompt to install the module:
Once the module is installed, type ‘exit’ to return back to your shell.
You can also directly install the module from the Terminal using command:
Install Perl modules using Cpanminus
Cpanminus or cpanm is a cpan client to get, unpack, build and install modules from CPAN repository. It is a standalone, dependency-free script that requires zero-configuration. Many experienced Perl developers prefer cpanm over cpan.
cpanminus can be installed in many ways.
1. Using Perl:
To install latest cpanm version on your Linux system, just run:
$ curl -L https://cpanmin.us | perl - --sudo App::cpanminus
This command will install cpanm system-wide and install cpanm binary to your bin directory like /usr/local/bin.
2. Using distribution’s package manager:
cpanm is also available in the default repositories of several Linux distributions. It is stable version, but bit old.
To install cpanminus on Arch Linux and its variants, run:
On Debian, Ubuntu, Linux Mint:
$ sudo apt install cpanminus
$ sudo yum install perl-App-cpanminus
3. Manual installation:
Alternatively, you can manually download latest cpanm binary and put it in your $PATH like below.
$ curl -L https://cpanmin.us/ -o cpanm
$ sudo mv cpanm /usr/local/bin/cpanm
After installing cpanm, you can install any Perl modul, for example Net::DNS, by running the following command from your Terminal:
Sample output:
--> Working on Net::DNS Fetching http://www.cpan.org/authors/id/N/NL/NLNETLABS/Net-DNS-1.21.tar.gz . OK Configuring Net-DNS-1.21 . OK ==> Found dependencies: Digest::HMAC --> Working on Digest::HMAC Fetching http://www.cpan.org/authors/id/G/GA/GAAS/Digest-HMAC-1.03.tar.gz . OK Configuring Digest-HMAC-1.03 . OK Building and testing Digest-HMAC-1.03 . OK Successfully installed Digest-HMAC-1.03 Building and testing Net-DNS-1.21 . OK Successfully installed Net-DNS-1.21 2 distributions installed
Install missing Perl modules using distribution’s package manager
Many Perl modules are available as packages, so you can install it using your distribution’s package manager.
$ apt-cache search 'perl$' | grep Net::DNS
libnet-dns-zonefile-fast-perl - fast BIND-style zonefile parser on top of Net::DNS
As you can see, the Net::DS module is provided by «libnet-dns-zonefile-fast-perl», so let us install it using command:
$ sudo apt install libnet-dns-zonefile-fast-perl
To find the missing module on Arch Linux, run:
$ pacman -Ss '^perl-' | grep Net::DNS
And install the missing module using ‘pacman’ command.
List installed Perl modules
To list the installed Perl modules, use ‘perldoc’ command:
Sample output:
Thu Jan 30 10:45:11 2020: "Module" Digest::HMAC * "installed into: /usr/local/share/perl/5.26.1" * "LINKTYPE: dynamic" * "VERSION: 1.03" * "EXE_FILES: " Thu Jan 30 10:47:41 2020: "Module" Net::DNS * "installed into: /usr/local/share/perl/5.26.1" * "LINKTYPE: dynamic" * "VERSION: 1.21" * "EXE_FILES: " Thu Jan 30 10:48:54 2020: "Module" Digest::BubbleBabble * "installed into: /usr/local/share/perl/5.26.1" * "LINKTYPE: dynamic" * "VERSION: 0.02" * "EXE_FILES: "
Another way to list the installed Perl modules is to use ‘instmodsh’ command like below.
You will see the following output:
Available commands are: l - List all installed modules m - Select a module q - Quit the program cmd?
In cmd prompt, type ‘l’ to list the modules.
Installed modules are: App::cpanminus Digest::BubbleBabble Digest::HMAC Module::Build Net::DNS Perl cmd?
Please note that the above two commands will list the modules installed with cpan. There could be many modules installed either manually or pre-installed with your Linux distribution.
To find all installed Perl modules, run:
Uninstall Perl modules
The Perl modules can be easily removed using cpanm using command:
$ sudo cpanm --uninstall Net::DNS
Type y and hit ENTER to remove the module long with all configuration files.
Net::DNS contains the following files: /usr/local/man/man3/Net::DNS.3pm /usr/local/man/man3/Net::DNS::Domain.3pm /usr/local/man/man3/Net::DNS::DomainName.3pm [. ] /usr/local/share/perl/5.26.1/Net/DNS/Text.pm /usr/local/share/perl/5.26.1/Net/DNS/Update.pm /usr/local/share/perl/5.26.1/Net/DNS/ZoneFile.pm Are you sure you want to uninstall Net::DNS? [y] y
Thanks for stopping by!
Help us to help you:
Have a Good day!!
Perl Download
We recommend that you always run the latest stable version, currently 5.38.0. If you’re running a version older than 5.8.3, you may find that the latest version of CPAN modules will not work.
Unix/Linux
macOS
Windows
Unix
Running Linux, Solaris, AIX, HPUX, or any other UNIX-like system?
Binaries
- Already Installed You probably already have perl installed. Type perl -v on a command line to find out which version.
- ActiveState Perl has binary distributions of Perl for many platforms. This is the simplest way to install the latest version of Perl. Download ActivePerl
Source
Consider looking at App::perlbrew to help compile and manage Perl from source.
Find out more about the source code, development versions as well as current releases of the Perl source code.
Mac OS X
Binaries
Mac OS X already has Perl installed. Open a Terminal application (in the Utilities folder of your Applications folder) and run perl -v to find out which version.
ActiveState Perl has binary distributions of Perl for Mac OS X. This is the simplest way to install the latest version of Perl.
Source
Consider looking at App::perlbrew to help compile and manage Perl from source.
Find out more about the source code, development versions as well as current releases of the Perl source code.
Windows
Windows does not have Perl installed by default.
Binaries
ActiveState Perl ActiveState offers both a free community version and a commercially supported binary distribution of Perl for Win32 and Perl for Win64.
Strawberry Perl: A 100% Open Source Perl for Windows that is exactly the same as Perl everywhere else; this includes using modules from CPAN, without the need for binary packages. Help is available from other Windows Perl developers on the #win32 irc channel on irc.perl.org (see website for access through a browser).
Source
Consider looking at App::perlbrew to help compile and manage Perl from source.
Find out more about the source code, development versions as well as current releases of the Perl source code.
How to Install Perl on Linux?
Before, we start with the process of Installing Perl on our System. We must have first-hand knowledge of What the Perl Language is and what it actually does?. Perl is a general-purpose, high level interpreted and dynamic programming language. Perl was originally developed for text processing like extracting the required information from a specified text file and for converting the text file into a different form. Perl supports both procedural and Object-Oriented programming. Perl is a lot similar to C syntactically and is easy for the users who have knowledge of C, C++.
Perl programs can be written on any plain text editor like gedit, notepad++, or anything of that sort. One can also use an online IDE for writing Perl codes or can even install one on their system to make it more feasible to write these codes. Using an IDE makes it easier to write Perl codes because IDEs provides a lot of features like intuitive code editor, debugger, compiler, etc.
To begin with, writing Perl Codes and performing various intriguing and useful operations, one must have Perl installed on their System. This can be done by following the step by step instructions provided below:
Checking for a preinstalled Perl version:
Before we begin with the installation of Perl, it is good to check if it might be already installed on your system, because many software applications nowadays require Perl to perform their operations, hence a version of Perl might be included in the software’s installation package and hence there is no need to redownload and install the Perl when it already exists. Many Linux systems have Perl preinstalled in their package.
To check if your device is preinstalled with Perl or not, open the terminal using Ctrl+Alt+T .
Now run the following command:
If Perl is already installed, it will generate a message with all the details of the Perl’s version available, otherwise if Perl is not installed then an error will arise stating Bad command or file name
Downloading and Installing Perl:
Downloading Perl:
Before starting with the installation process, you need to download it. For that, all versions of Perl for Linux are available on perl.org
Download the Perl and follow the further instructions for installation of Perl.
Beginning with the Installation:
- Changing Directory to install Perl:
- Starting the Installation Process:
- Choosing the Directory to Install Perl:
- Finishing the Installation:
After completing the installation process, any IDE or text editor can be used to write Perl Codes and Run them on the IDE or the Command prompt with the use of command:
Here’s a sample Program to begin with the use of Perl Programming:
Let’s consider a simple Hello World Program.