Table of Contents
In this article, I will take you through the steps to Install Perl 5.16 on RedHat/CentOS 7.
Perl is an interpreted, multi-platform high-level programming language developed by Larry Wall. It is the Swiss Army knife of scripting languages.
Perl 1.0 was released in 1987, and at the time of writing this article on Steps to Install Perl on RedHat/CentOS 7, I am using version 5.16.
Also Read: How to install Python 3 on CentOS 7
Perl programming can be done by either executing Perl commands at the shell prompt or by writing them in a text file, and then executing it as a Perl Script.
Steps to Install Perl on RedHat/CentOS 7 is fairly straight forward. In next article, i will take you through another method to install perl on CentOS.
Install Perl on RedHat/CentOS 7
Before we go through the steps to install Perl on RedHat/CentOS 7, you need to have the prerequisites in place.
Prerequisites
You need to have a running RedHat/CentOS 7 System with root access. Below are the minimum CPU and Memory configuration required:-
Processor: 1CPU
Memory: 1GB
Update System
Firstly we need to update the system through yum update command as shown below.
[root@localhost ~]# yum update
Loaded plugins: fastestmirror
Determining fastest mirrors
* base: centos.excellmedia.net
* extras: centos.excellmedia.net
* updates: centos.excellmedia.net
base | 3.6 kB 00:00
extras | 2.9 kB 00:00
updates | 2.9 kB 00:00
updates/7/x86_64/primary_db | 1.9 MB 00:00
Resolving Dependencies
--> Running transaction check
---> Package kernel.x86_64 0:3.10.0-1062.1.2.el7 will be installed
---> Package kernel-tools.x86_64 0:3.10.0-1062.1.1.el7 will be updated
---> Package kernel-tools.x86_64 0:3.10.0-1062.1.2.el7 will be an update
---> Package kernel-tools-libs.x86_64 0:3.10.0-1062.1.1.el7 will be updated
---> Package kernel-tools-libs.x86_64 0:3.10.0-1062.1.2.el7 will be an update
---> Package python-perf.x86_64 0:3.10.0-1062.1.1.el7 will be updated
---> Package python-perf.x86_64 0:3.10.0-1062.1.2.el7 will be an update
--> Finished Dependency Resolution
Dependencies Resolved
========================================================================================================================================================================
Package Arch Version Repository Size
========================================================================================================================================================================
Installing:
kernel x86_64 3.10.0-1062.1.2.el7 updates 50 M
Updating:
kernel-tools x86_64 3.10.0-1062.1.2.el7 updates 7.8 M
kernel-tools-libs x86_64 3.10.0-1062.1.2.el7 updates 7.7 M
python-perf x86_64 3.10.0-1062.1.2.el7 updates 7.8 M
Transaction Summary
========================================================================================================================================================================
Install 1 Package
Upgrade 3 Packages
Total download size: 73 M
Is this ok [y/d/N]: y
Downloading packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
(1/4): kernel-tools-3.10.0-1062.1.2.el7.x86_64.rpm | 7.8 MB 00:00:02
(2/4): kernel-tools-libs-3.10.0-1062.1.2.el7.x86_64.rpm | 7.7 MB 00:00:01
(3/4): python-perf-3.10.0-1062.1.2.el7.x86_64.rpm | 7.8 MB 00:00:01
(4/4): kernel-3.10.0-1062.1.2.el7.x86_64.rpm | 50 MB 00:00:11
------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Install Perl Package
Once System is fully updated, you can install perl package through yum install perl command as shown below.
[root@localhost ~]# yum install perl
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: centos.excellmedia.net
* extras: centos.excellmedia.net
* updates: centos.excellmedia.net
Resolving Dependencies
--> Running transaction check
---> Package perl.x86_64 4:5.16.3-294.el7_6 will be installed
--> Processing Dependency: perl-libs = 4:5.16.3-294.el7_6 for package: 4:perl-5.16.3-294.el7_6.x86_64
--> Processing Dependency: perl(Socket) >= 1.3 for package: 4:perl-5.16.3-294.el7_6.x86_64
--> Processing Dependency: perl(Scalar::Util) >= 1.10 for package: 4:perl-5.16.3-294.el7_6.x86_64
--> Processing Dependency: perl-macros for package: 4:perl-5.16.3-294.el7_6.x86_64
--> Processing Dependency: perl-libs for package: 4:perl-5.16.3-294.el7_6.x86_64
--> Processing Dependency: perl(threads::shared) for package: 4:perl-5.16.3-294.el7_6.x86_64
--> Processing Dependency: perl(threads) for package: 4:perl-5.16.3-294.el7_6.x86_64
--> Processing Dependency: perl(constant) for package: 4:perl-5.16.3-294.el7_6.x86_64
--> Processing Dependency: perl(Time::Local) for package: 4:perl-5.16.3-294.el7_6.x86_64
--> Processing Dependency: perl(Time::HiRes) for package: 4:perl-5.16.3-294.el7_6.x86_64
--> Processing Dependency: perl(Storable) for package: 4:perl-5.16.3-294.el7_6.x86_64
--> Processing Dependency: perl(Socket) for package: 4:perl-5.16.3-294.el7_6.x86_64
--> Processing Dependency: perl(Scalar::Util) for package: 4:perl-5.16.3-294.el7_6.x86_64
--> Processing Dependency: perl(Pod::Simple::XHTML) for package: 4:perl-5.16.3-294.el7_6.x86_64
--> Processing Dependency: perl(Pod::Simple::Search) for package: 4:perl-5.16.3-294.el7_6.x86_64
--> Processing Dependency: perl(Getopt::Long) for package: 4:perl-5.16.3-294.el7_6.x86_64
--> Processing Dependency: perl(Filter::Util::Call) for package: 4:perl-5.16.3-294.el7_6.x86_64
--> Processing Dependency: perl(File::Temp) for package: 4:perl-5.16.3-294.el7_6.x86_64
--> Processing Dependency: perl(File::Spec::Unix) for package: 4:perl-5.16.3-294.el7_6.x86_64
--> Processing Dependency: perl(File::Spec::Functions) for package: 4:perl-5.16.3-294.el7_6.x86_64
--> Processing Dependency: perl(File::Spec) for package: 4:perl-5.16.3-294.el7_6.x86_64
--> Processing Dependency: perl(File::Path) for package: 4:perl-5.16.3-294.el7_6.x86_64
--> Processing Dependency: perl(Exporter) for package: 4:perl-5.16.3-294.el7_6.x86_64
--> Processing Dependency: perl(Cwd) for package: 4:perl-5.16.3-294.el7_6.x86_64
--> Processing Dependency: perl(Carp) for package: 4:perl-5.16.3-294.el7_6.x86_64
--> Processing Dependency: libperl.so()(64bit) for package: 4:perl-5.16.3-294.el7_6.x86_64
--> Running transaction check
---> Package perl-Carp.noarch 0:1.26-244.el7 will be installed
---> Package perl-Exporter.noarch 0:5.68-3.el7 will be installed
---> Package perl-File-Path.noarch 0:2.09-2.el7 will be installed
---> Package perl-File-Temp.noarch 0:0.23.01-3.el7 will be installed
---> Package perl-Filter.x86_64 0:1.49-3.el7 will be installed
---> Package perl-Getopt-Long.noarch 0:2.40-3.el7 will be installed
--> Processing Dependency: perl(Pod::Usage) >= 1.14 for package: perl-Getopt-Long-2.40-3.el7.noarch
--> Processing Dependency: perl(Text::ParseWords) for package: perl-Getopt-Long-2.40-3.el7.noarch
---> Package perl-PathTools.x86_64 0:3.40-5.el7 will be installed
---> Package perl-Pod-Simple.noarch 1:3.28-4.el7 will be installed
--> Processing Dependency: perl(Pod::Escapes) >= 1.04 for package: 1:perl-Pod-Simple-3.28-4.el7.noarch
--> Processing Dependency: perl(Encode) for package: 1:perl-Pod-Simple-3.28-4.el7.noarch
---> Package perl-Scalar-List-Utils.x86_64 0:1.27-248.el7 will be installed
---> Package perl-Socket.x86_64 0:2.010-4.el7 will be installed
---> Package perl-Storable.x86_64 0:2.45-3.el7 will be installed
---> Package perl-Time-HiRes.x86_64 4:1.9725-3.el7 will be installed
---> Package perl-Time-Local.noarch 0:1.2300-2.el7 will be installed
---> Package perl-constant.noarch 0:1.27-2.el7 will be installed
---> Package perl-libs.x86_64 4:5.16.3-294.el7_6 will be installed
---> Package perl-macros.x86_64 4:5.16.3-294.el7_6 will be installed
---> Package perl-threads.x86_64 0:1.87-4.el7 will be installed
---> Package perl-threads-shared.x86_64 0:1.43-6.el7 will be installed
--> Running transaction check
---> Package perl-Encode.x86_64 0:2.51-7.el7 will be installed
---> Package perl-Pod-Escapes.noarch 1:1.04-294.el7_6 will be installed
---> Package perl-Pod-Usage.noarch 0:1.63-3.el7 will be installed
--> Processing Dependency: perl(Pod::Text) >= 3.15 for package: perl-Pod-Usage-1.63-3.el7.noarch
--> Processing Dependency: perl-Pod-Perldoc for package: perl-Pod-Usage-1.63-3.el7.noarch
---> Package perl-Text-ParseWords.noarch 0:3.29-4.el7 will be installed
--> Running transaction check
---> Package perl-Pod-Perldoc.noarch 0:3.20-4.el7 will be installed
--> Processing Dependency: perl(parent) for package: perl-Pod-Perldoc-3.20-4.el7.noarch
--> Processing Dependency: perl(HTTP::Tiny) for package: perl-Pod-Perldoc-3.20-4.el7.noarch
---> Package perl-podlators.noarch 0:2.5.1-3.el7 will be installed
--> Running transaction check
---> Package perl-HTTP-Tiny.noarch 0:0.033-3.el7 will be installed
---> Package perl-parent.noarch 1:0.225-244.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
========================================================================================================================================================================
Package Arch Version Repository Size
========================================================================================================================================================================
Installing:
perl x86_64 4:5.16.3-294.el7_6 base 8.0 M
Installing for dependencies:
perl-Carp noarch 1.26-244.el7 base 19 k
perl-Encode x86_64 2.51-7.el7 base 1.5 M
perl-Exporter noarch 5.68-3.el7 base 28 k
perl-File-Path noarch 2.09-2.el7 base 26 k
perl-File-Temp noarch 0.23.01-3.el7 base 56 k
...................
Verify the Package
Once the perl package is installed, you can verify it through rpm database by using rpm -qa command.
[root@localhost ~]# rpm -qa | grep -i perl-5.16
perl-5.16.3-294.el7_6.x86_64
Check Perl Version
Since the package is installed now, you can check the Perl version through perl -v command.
[root@localhost ~]# perl -v
This is perl 5, version 16, subversion 3 (v5.16.3) built for x86_64-linux-thread-multi
(with 39 registered patches, see perl -V for more detail)
Write your first Perl Script
Let's write one simple Perl script printing hello world.
[root@localhost ~]# cat HelloWorld.pl
#!/usr/bin/perl
use warnings;
print("Hello World\n");
Check the Output
As you can see above script can be run by using perl HelloWorld.pl command which gives us the output Hello World as expected.
[root@localhost ~]# perl HelloWorld.pl
Hello World
Also Read: Constructors in C++
Reference: Perl Documentation
In the next article, i will show you how to install Perl on Windows and Mac.