Install Perl and check the version
Is Perl installed
Perl ships with Linux, macOS and most UNIX systems, so there is a good chance you already have it. Ask your shell where the program lives:
which perl
/usr/bin/perl
An empty answer means Perl is missing. The per-system pages below cover the install for each operating system: Ubuntu, Rocky Linux, macOS, FreeBSD, Windows 11.
perl -v
The version flag prints a short banner followed by a copyright notice. The first line is the one that matters: it carries the language version and the patch level.
perl -v
This is perl 5, version 38, subversion 2 (v5.38.2) built for x86_64-linux-gnu-thread-multi
Any release from 5.20 upward runs everything in this course. Do not worry if your number differs from the one above: Perl adds features without breaking old code.
One version, in detail
When a bug report needs the exact build, ask for a single configuration value instead of the whole banner. The version variable answers in the numeric form that scripts compare against:
perl -V:version
version='5.038002';
Inside a program the same data is available as $], the numeric version, and $^V, the version object. Both are described in the next lessons.
Several versions side by side
System Perl belongs to the operating system, and upgrading it can break tools the system depends on. For experiments, install a private copy with perlbrew (or plenv, which works the same way). Both keep every version under your home folder and switch with a shell command.
Install perlbrew, then build and switch to the newest stable release:
curl -L https://install.perlbrew.pl | bash
perlbrew install perl-stable
perlbrew switch perl-stable
Future lessons use the Perl you just checked. If you installed a private copy, close the terminal and open a new one so the shell picks up the new path; the notes on PATH explain why that helps.
Next: Your first Perl script
Article author: Arthur Isaev