Install Perl on Rocky Linux

Contents
What Rocky ships
Install with dnf
Modules and cpanm
Newer Perl with perlbrew

What Rocky ships

Rocky Linux, like every RHEL clone, includes Perl because the system tools need it. The base install is a single release line that receives security fixes but no new features.

perl -v

This is perl 5, version 32, subversion 1 (v5.32.1) built for x86_64-linux-thread-multi

5.32 is old enough to miss subroutine signatures, so lesson 49 will not compile on it. Everything else in the course runs. If you want the modern line, skip to the perlbrew section at the end.

Install with dnf

The interpreter is usually present, but the documentation and the command line tools may not be. Install the base package and the utilities together:

sudo dnf install perl perl-utils

perl-utils brings perldoc, which turns every core module into searchable documentation. Check that it works before you need it:

perldoc -f open

open FILEHANDLE,EXPR open FILEHANDLE,MODE,EXPR open FILEHANDLE,MODE,EXPR,LIST

Modules and cpanm

RPM packages for CPAN modules follow a naming rule: perl-JSON-PP for JSON::PP, perl-Text-CSV for Text::CSV. dnf also resolves the virtual name, which is easier to read:

sudo dnf install 'perl(JSON::PP)' 'perl(Text::CSV)'

cpanm is not in the base repositories. Enable EPEL and install it from there, or bootstrap it with the one-line installer if you prefer not to add a repository:

sudo dnf install epel-release

sudo dnf install perl-App-cpanminus

Once it is in place, cpanm --installdeps . reads a cpanfile and installs everything a project needs. That is the same command you would run on any other Linux.

Newer Perl with perlbrew

Building a newer Perl needs the compiler and the development libraries. Install them first, then perlbrew:

sudo dnf groupinstall 'Development Tools'

curl -L https://install.perlbrew.pl | bash

Add the line the installer prints to ~/.bashrc, open a new shell, and build the release you want:

perlbrew install perl-5.40.0

perlbrew switch perl-5.40.0

The build takes several minutes on a small VM. If it fails while linking, the usual cause is a missing libxcrypt-devel or an old gcc; the log names the missing piece.

Keep the shebang portable with #!/usr/bin/env perl so scripts follow the Perl your shell finds, not the one in /usr/bin.

Next: Install Perl on macOS

Article author: Arthur Isaev

Related articles
Perl
Perl course: zero to hero in 50 lessons
What is Perl and where it runs
Install Perl and check the version
Your first Perl script
The debugger as a REPL
Scalars and sigils
Numbers
Strings
Interpolation and quoting
Arrays
push, pop, shift and splice
Hashes
keys, values, exists and delete
Scalar and list context
Conditions and comparison
while, for, next and last
foreach and the default variable
Subroutines
Arguments in @_
References
Nested data structures
Regular expressions: match and anchors
Captures and named groups
Substitution with s///
split and join
grep and map
Sort and the Schwartzian transform
Read and write files
File tests and metadata
Directories and paths
die, warn and eval
Modules and Exporter
CPAN and cpanm
Objects with bless
Modern objects with Moo
Testing with Test::More
strict, warnings and diagnostics
Options with Getopt::Long
Environment and %ENV
system, backticks and pipes
One-liners with -n and -p
CSV and TSV processing
JSON with JSON::PP
HTTP clients with HTTP::Tiny
Sockets and IO::Socket
Databases with DBI
Capstone: todo CLI
Capstone: log report
Performance and profiling
Modern Perl tour
Hero roadmap: the whole course on one page
Install Perl on Windows 11
Install Perl on Ubuntu
Install Perl on Rocky Linux
Install Perl on macOS
Install Perl on FreeBSD
Perl in Docker

Search this site

Channel @aofeed Chat @aofeedchat

Contacts and cooperation:
I recommend our hosting beget.com
Write to info@aredel.com if you:
1. Want to write an article for our site or translate an article into your native language.
2. Want to place thematically relevant ads on the site.
3. Ads on my site pass maximum censorship. If you see an ad block unsuitable for school-age children, shocking or misleading - please contact us by e-mail
4. Found a mistake, inaccuracy, bug, etc. on the site. ... .......
5. Articles can be shared on social media by clicking a network icon: