Installing Perl
Learn how Perl ships by default on most Linux and macOS systems, how to install it on Windows with Strawberry Perl, and how to verify your installation.
Introduction
Before writing your first real Perl script, you need a working Perl interpreter on your machine. The good news is that most developers, especially those on Linux or macOS, likely already have Perl installed. This lesson covers all three major platforms and shows you how to confirm everything is working correctly.
- Why Perl is usually already installed on Linux and macOS.
- How to install Perl on Windows using Strawberry Perl.
- How to verify your Perl version from the command line.
Perl on Linux
Nearly every mainstream Linux distribution ships with Perl pre-installed, because many core system tools and package managers rely on it internally. Open a terminal and check for it first before installing anything.
perl -vIf that command prints version information, you are already set up. If Perl is genuinely missing (rare, but possible on minimal container images), install it with your distribution's package manager.
# Debian / Ubuntusudo apt updatesudo apt install perl
# Fedora / RHEL / CentOSsudo dnf install perl
# Arch Linuxsudo pacman -S perlPerl on macOS
macOS also ships with a system version of Perl pre-installed. You can confirm this immediately in Terminal.
perl -vApple's bundled Perl can be an older version and is tied to internal macOS tooling, so many developers prefer installing an independent, up-to-date copy with Homebrew instead of relying on or modifying the system one.
# Install Homebrew's Perl (recommended for development)brew install perlInstalling Perl on Windows
Windows does not include Perl by default, so you will need to install it yourself. The most popular option for Windows developers is Strawberry Perl, a distribution that bundles the Perl interpreter together with a C compiler and common build tools, making it easy to install CPAN modules that need to compile native code.
- Go to strawberryperl.com in your browser.
- Download the latest 64-bit installer (.msi) for your version of Windows.
- Run the installer and accept the default installation options.
- Open a new Command Prompt or PowerShell window after installation completes (so it picks up the updated PATH).
If you use Windows Subsystem for Linux (WSL), you can instead follow the Linux installation instructions inside your WSL distribution, which gives you the same Perl experience as a native Linux machine.
Verifying Your Installation
Regardless of platform, the same command confirms Perl is installed and shows you exactly which version you are running.
perl -vClick Run to see what this code prints.
You can also check where the interpreter itself lives on your system, which is occasionally useful for troubleshooting multiple installed versions.
perl -e 'print $^X, "\n";'Click Run to see what this code prints.
Choosing an Editor
Any plain text editor can write Perl scripts, but a code-aware editor makes learning much smoother. Visual Studio Code with a Perl extension (such as "Perl" or "Perl Navigator") gives you syntax highlighting and basic linting, which will help you catch typos before you even run your script.
Common Mistakes
- Installing a second Perl on Linux/macOS without checking whether one already exists — leading to confusing PATH conflicts.
- Modifying or deleting the macOS system Perl, which some OS-level tools depend on.
- Forgetting to open a new terminal window after installing on Windows, so the PATH update has not taken effect yet.
- Downloading Strawberry Perl from an unofficial mirror instead of strawberryperl.com.
Best Practices
- Always run perl -v first to check if Perl is already available before installing anything.
- On macOS, prefer a Homebrew-installed Perl for development work rather than the bundled system Perl.
- On Windows, use Strawberry Perl rather than trying to hand-build Perl from source.
- Keep your Perl installation reasonably current to access modern syntax features covered later in this course.
Frequently Asked Questions
Any Perl 5.10 or later will run every example in this course comfortably; a recent release such as 5.36 or newer is recommended so modern syntax works without extra pragmas.
Yes, browser-based Perl playgrounds exist and are fine for quick experiments, but installing Perl locally is recommended so you can practice file handling and command-line scripts covered later in this course.
Strawberry Perl is generally the recommended free option today; ActivePerl's free community distribution has become more limited over time, so most learners are better served by Strawberry Perl.
Key Takeaways
- Perl ships by default on nearly all Linux distributions and on macOS.
- Windows users should install Strawberry Perl, which bundles Perl with essential build tools.
- perl -v verifies your installed version and confirms Perl is on your PATH.
- A code-aware editor like VS Code with a Perl extension makes learning easier.
Summary
With Perl installed and verified, you are ready to write and run real code. The next lesson walks through your very first complete Perl script, including the shebang line and what use strict and use warnings actually do.