Skip to content
perl: command not found

perl: command not found

DodaTech 2 min read

The “perl: command not found” error means your operating system cannot locate the Perl interpreter in any directory listed in your PATH environment variable.

What It Means

When you type perl in your terminal, the shell searches through every directory in your PATH variable to find an executable named perl. If none of those directories contain the Perl binary, the shell returns “command not found.” Perl is not installed by default on most systems — it must be installed separately.

Why It Happens

  • Perl is not installed on your system.
  • Perl is installed but its binary directory (e.g., /usr/bin or /usr/local/bin) is not in your PATH.
  • You’re using a minimal Docker container or WSL image that doesn’t include Perl.
  • The installation was incomplete or corrupted.
  • You opened a new terminal session that hasn’t loaded the updated PATH.

How to Fix It

1. Install Perl via your package manager

Ubuntu / Debian:

sudo apt update
sudo apt install perl

CentOS / RHEL / Fedora:

sudo dnf install perl
# or on older systems
sudo yum install perl

macOS (Homebrew):

brew install perl

Windows (Chocolatey):

choco install perl

2. Verify the installation

perl --version

# Expected output (version may vary):
# This is perl 5, version 38, subversion 2 (v5.38.2)

3. Check your PATH if Perl is installed but not found

# Locate the Perl binary
which perl
# or
find /usr -name perl -type f 2>/dev/null

# If found, add its directory to your PATH
export PATH="$PATH:/usr/local/bin/perl"
# Add to ~/.bashrc or ~/.zshrc for permanence

4. Restart your terminal session

After installing, close and reopen your terminal or run:

exec $SHELL -l

5. For Docker containers

If Perl is missing from your Docker image, add it to your Dockerfile:

RUN apt-get update && apt-get install -y perl
Do I need Perl to run Perl scripts?
Yes — Perl scripts are not compiled binaries. They are interpreted at runtime by the Perl interpreter (perl). Without the interpreter, the operating system has no way to parse and execute the .pl file.
Can I use a one-liner instead of a script?
Yes — Perl supports one-liners with the -e flag: perl -e 'print "Hello\n"'. This is useful for quick text processing without creating a file. But you still need perl installed to use them.
What’s the difference between perl and perl5?
On some systems, perl is a symlink to perl5 (the Perl 5 interpreter). Perl 6 / Raku is a separate language with its own binary (raku). Always check with perl --version to confirm which version you’re running.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro