How to Install Perl on Arch Linux

Install Perl on Arch Linux with pacman. Covers CPAN module management, perlbrew for multiple versions, and PATH configuration.

Last updatedAuthorJoshua JamesRead time7 minGuide typeArch Linux

Perl on Arch Linux is the system-packaged interpreter for text processing, automation scripts, CPAN modules, and older tools that still depend on Perl. Arch provides it as the official perl package, while helper commands such as perldoc, cpan, cpanm, and perlbrew need one Arch-specific PATH adjustment after installation.

The recommended path uses pacman for the interpreter, verifies package and command ownership, sets up the extra Perl tool paths, shows the safest choices for installing modules, and explains when not to remove the system Perl package.

Update Arch Linux Before Installing Perl

Synchronize package databases and upgrade the system first. Arch is a rolling release, so installing packages against stale metadata can create dependency conflicts:

sudo pacman -Syu

These commands use sudo for tasks that need root privileges. If your user is not in the sudoers file yet, run the commands as root or follow the guide on how to add and manage sudo users on Arch Linux.

Install Perl on Arch Linux

The official Arch perl package installs the interpreter, core modules, CPAN.pm, and documentation files. Minimal Arch systems do not necessarily include it, while development workstations may already have it because packages such as Git or build tools depend on Perl.

Install Perl from the Official Repository

Install the package with pacman:

sudo pacman -S perl

If pacman reports that perl is already installed, keep the package in place. On many Arch desktops and development machines, Perl is a dependency of other repository packages rather than an isolated optional tool.

Verify Perl and Package Ownership

Check the installed Perl version:

perl -v | head -5

Relevant output starts with the active Perl branch on your updated Arch system:

This is perl 5, version 42, subversion x (v5.42.x) built for x86_64-linux-thread-multi

Confirm the active binary path and the package that owns it:

command -v perl
pacman -Qo "$(command -v perl)"
/usr/bin/perl
/usr/bin/perl is owned by perl 5.42.x-1

Package ownership matters because CPAN, perlbrew, or local shell paths should not replace Arch’s package-owned /usr/bin/perl binary.

Configure Perl Tool Paths on Arch Linux

Arch installs the main perl binary in /usr/bin, but places some bundled tools under /usr/bin/core_perl and package-provided Perl tools under /usr/bin/vendor_perl. Without those directories in your shell PATH, commands such as perldoc, cpan, cpanm, and perlbrew can return command not found even when their packages are installed.

Add both directories to Bash without duplicating the line on later runs:

touch ~/.bashrc
grep -qxF 'export PATH="/usr/bin/core_perl:/usr/bin/vendor_perl:$PATH"' ~/.bashrc || printf '%s\n' 'export PATH="/usr/bin/core_perl:/usr/bin/vendor_perl:$PATH"' >> ~/.bashrc
source ~/.bashrc

For Zsh, apply the same line to ~/.zshrc:

touch ~/.zshrc
grep -qxF 'export PATH="/usr/bin/core_perl:/usr/bin/vendor_perl:$PATH"' ~/.zshrc || printf '%s\n' 'export PATH="/usr/bin/core_perl:/usr/bin/vendor_perl:$PATH"' >> ~/.zshrc
source ~/.zshrc

Verify that the bundled documentation and CPAN shell commands are now discoverable:

command -v perldoc
command -v cpan
/usr/bin/core_perl/perldoc
/usr/bin/core_perl/cpan

Read Perl’s built-in documentation with perldoc:

perldoc -f print | head -10
    print FILEHANDLE LIST
    print FILEHANDLE
    print LIST
    print   Prints a string or a list of strings. Returns true if
            successful.

To read documentation for a specific core module, pass its module name to perldoc:

perldoc JSON::PP

Install Perl Modules on Arch Linux

Perl modules can come from Arch packages or from CPAN. Prefer pacman packages when they exist because pacman tracks files, dependencies, and updates; use CPAN tools for modules or versions that Arch does not package.

MethodSourceUpdate PathBest For
Pacman packagesArch repositoriesSystem upgrade through pacmanSystem-integrated modules and most routine installs
cpanminusCPANManual reinstall or CPAN workflowModules not packaged by Arch or project-specific version needs
CPAN shellCPANInteractive CPAN workflowUsers who prefer CPAN’s built-in interactive configuration
local::libPer-user library pathUser-managed CPAN modulesNon-root module installs in a home-directory module tree

Install Perl Modules with Pacman

Search the repositories for packaged Perl modules:

pacman -Ss '^perl-' | head -20

Package versions vary as Arch updates, but the output uses the repository/package format:

extra/perl-dbi 1.647-2
    Database independent interface for Perl
extra/perl-json 4.11-1
    JSON (JavaScript Object Notation) encoder/decoder
extra/perl-lwp-protocol-https 6.15-1
    Provide https support for LWP::UserAgent

Install only the modules your script needs. For example, DBI, JSON, and HTTPS support for LWP::UserAgent install as separate Arch packages:

sudo pacman -S perl-dbi perl-json perl-lwp-protocol-https

Verify a module by loading it with Perl:

perl -MDBI -e 'print "DBI $DBI::VERSION\n"'
perl -MJSON -e 'print "JSON $JSON::VERSION\n"'
perl -MLWP::Protocol::https -e 'print "LWP::Protocol::https $LWP::Protocol::https::VERSION\n"'
DBI 1.x
JSON 4.x
LWP::Protocol::https 6.x

Install Perl Modules with cpanminus

The official Arch cpanminus package provides the cpanm command for installing modules from CPAN with less interactive setup than the traditional CPAN shell.

sudo pacman -S cpanminus

After the PATH adjustment, confirm the command path and package ownership:

command -v cpanm
pacman -Qo "$(command -v cpanm)"
cpanm --version | head -3
/usr/bin/vendor_perl/cpanm
/usr/bin/vendor_perl/cpanm is owned by cpanminus 1.704x-1
cpanm (App::cpanminus) version 1.704x (/usr/bin/vendor_perl/cpanm)

Install a CPAN module system-wide only when you intentionally want it outside pacman’s module packages. Use the full path so the command still works on systems where sudo does not inherit the vendor_perl PATH entry:

sudo /usr/bin/vendor_perl/cpanm Mojolicious

Do not use CPAN tools to overwrite Arch package files under /usr/bin or to replace the system Perl interpreter. Prefer pacman packages for system modules when they exist, and keep CPAN installs project-local or user-local when possible.

Install Perl Modules in Your Home Directory

For non-root module installs, use local::lib. Arch packages it as perl-local-lib, which avoids bootstrapping the helper from CPAN before your user module path exists:

sudo pacman -S perl-local-lib

Add the local library environment to Bash with a duplicate-safe line:

touch ~/.bashrc
grep -qxF 'eval "$(perl -Mlocal::lib=~/perl5)"' ~/.bashrc || printf '%s\n' 'eval "$(perl -Mlocal::lib=~/perl5)"' >> ~/.bashrc
source ~/.bashrc

After that shell environment is active, plain cpanm installs modules under ~/perl5 instead of requiring root:

cpanm Module::Name

Use the CPAN Shell

The cpan command is bundled with the Arch perl package under /usr/bin/core_perl/cpan. Start it after the PATH adjustment:

cpan

On first run, CPAN asks whether it should configure itself automatically. The default automatic configuration is enough for most users:

Would you like to configure as much as possible automatically? [yes]

When the CPAN prompt appears, install modules by name, then exit the shell:

cpan[1]> install Data::Dumper
cpan[2]> exit

Test Perl on Arch Linux

Create and run a small script to confirm the interpreter can execute a normal Perl file:

cat > hello.pl <<'EOF'
#!/usr/bin/env perl
use strict;
use warnings;

print "Hello, World!\n";
print "Perl version: $^V\n";
EOF

chmod +x hello.pl
./hello.pl
Hello, World!
Perl version: v5.42.x

You can also run the script without setting executable permissions:

perl hello.pl

Test a one-liner for quick text substitution:

echo "hello world" | perl -pe 's/world/Arch Linux/'
hello Arch Linux

Remove the temporary script when you are done testing:

rm -f hello.pl

Manage Multiple Perl Versions with Perlbrew

Use the system Perl for normal Arch packages and scripts. If you need separate interpreters for project testing, the official Arch perlbrew package manages additional Perl builds under your home directory without replacing /usr/bin/perl.

sudo pacman -S perlbrew

Verify the command after the PATH adjustment:

command -v perlbrew
perlbrew --version
/usr/bin/vendor_perl/perlbrew
/usr/bin/vendor_perl/perlbrew  - App::perlbrew/1.x

Initialize perlbrew for your account, then add its shell environment to Bash:

perlbrew init
touch ~/.bashrc
grep -qxF 'source ~/perl5/perlbrew/etc/bashrc' ~/.bashrc || printf '%s\n' 'source ~/perl5/perlbrew/etc/bashrc' >> ~/.bashrc
source ~/.bashrc

List available Perl releases and install the branch your project needs:

perlbrew available
perlbrew install perl-5.40.4
perlbrew switch perl-5.40.4

Compiling an alternate Perl version can take several minutes. Return to Arch’s packaged interpreter when you no longer need the project-specific build:

perlbrew switch perl-system

Update or Remove Perl from Arch Linux

Update Perl and Perl Module Packages

Update Arch-managed Perl packages with the normal system upgrade:

sudo pacman -Syu

Modules installed through CPAN tools are not owned by pacman. Reinstall or update those modules inside the same CPAN, local::lib, or perlbrew environment that originally installed them.

Remove Optional Perl Tools and Modules

Remove optional Perl tools and module packages by package name when you installed them only for this workflow. Preview each cleanup first, and keep packages that other scripts, applications, or Perl environments still use.

sudo pacman -Rs cpanminus --print

If the preview only lists cpanminus and packages you no longer need, remove it:

sudo pacman -Rns cpanminus

If you used perlbrew and no longer need its packaged helper or local::lib dependency, preview that cleanup separately:

sudo pacman -Rs perlbrew perl-local-lib --print

Then remove both in the same transaction when the preview matches your intended cleanup:

sudo pacman -Rns perlbrew perl-local-lib

If you installed the example module packages only for testing, preview their dependency cleanup separately from the helper tools:

sudo pacman -Rs perl-dbi perl-json perl-lwp-protocol-https --print

The preview can include HTTPS and web-client support libraries such as perl-libwww or perl-io-socket-ssl. Continue only when those packages are not needed elsewhere:

sudo pacman -Rns perl-dbi perl-json perl-lwp-protocol-https

Verify package-manager state after removal. This loop reports any package that is no longer installed and prints the version for anything still present:

for pkg in cpanminus perlbrew perl-local-lib perl-dbi perl-json perl-lwp-protocol-https; do
    pacman -Q "$pkg" 2>/dev/null || printf '%s is not installed\n' "$pkg"
done
cpanminus is not installed
perlbrew is not installed
perl-local-lib is not installed
perl-dbi is not installed
perl-json is not installed
perl-lwp-protocol-https is not installed

Remove the System Perl Package Only When Safe

Do not force-remove perl. Pacman will refuse removal when installed packages still depend on it, and force-removal flags can leave package-owned tools such as Git or build utilities broken.

Preview whether your system can remove the main Perl package without breaking dependencies:

sudo pacman -Rs perl --print

If other packages require Perl, pacman prints dependency errors similar to this:

error: failed to prepare transaction (could not satisfy dependencies)
:: removing perl breaks dependency 'perl' required by git
:: removing perl breaks dependency 'perl' required by autoconf

Keep perl installed when you see dependency errors. If the preview shows that only Perl and orphaned dependencies would be removed, then remove it with the complete cleanup flags:

sudo pacman -Rns perl

Verify the package is no longer installed:

pacman -Q perl
error: package 'perl' was not found

Per-user CPAN and perlbrew files remain under your home directory. Remove them only when you no longer need those modules or alternate interpreters:

rm -rf ~/perl5

If you added PATH or perlbrew lines to ~/.bashrc or ~/.zshrc, remove those lines from the shell file you changed.

Troubleshoot Perl on Arch Linux

perldoc, cpan, cpanm, or perlbrew: command not found

If helper commands are missing after package installation, first check whether the files exist outside your PATH:

ls /usr/bin/core_perl/perldoc /usr/bin/core_perl/cpan /usr/bin/vendor_perl/cpanm /usr/bin/vendor_perl/perlbrew 2>/dev/null
/usr/bin/core_perl/cpan
/usr/bin/core_perl/perldoc
/usr/bin/vendor_perl/cpanm
/usr/bin/vendor_perl/perlbrew

If the files exist, reload your shell configuration or open a new terminal:

source ~/.bashrc
command -v perldoc cpan cpanm perlbrew

If a file is missing, install the package that owns it. perldoc and cpan come from perl, cpanm comes from cpanminus, and perlbrew comes from perlbrew.

Can’t locate CPAN.pm in @INC

This error means the active Perl interpreter cannot find the bundled CPAN module:

Can't locate CPAN.pm in @INC (you may need to install the CPAN module)

On Arch, CPAN.pm is provided by the official perl package. Confirm the module loads under the interpreter you are using:

perl -MCPAN -e 'print "CPAN $CPAN::VERSION\n"'
pacman -Qo /usr/bin/core_perl/cpan
CPAN 2.x
/usr/bin/core_perl/cpan is owned by perl 5.42.x-1

If the command fails while perlbrew is active, switch back to the system Perl or install the module for that perlbrew-managed interpreter:

perlbrew switch perl-system

Can’t locate Module/Name.pm in @INC

When a script cannot find a module, inspect the active interpreter’s module search paths:

perl -V | grep -A 20 '@INC'

Then install the module for the interpreter and scope you are actually using. For system modules, search pacman first:

pacman -Ss '^perl-dbi$'
sudo pacman -S perl-dbi

For a perlbrew or local::lib environment, activate that environment first, then install with cpanm:

cpanm Module::Name

CPAN Permission Denied Errors

A permission error usually means a CPAN tool is trying to write to system-owned Perl directories without root access:

ERROR: Can't create '/usr/lib/perl5/site_perl/...'
Permission denied

For a one-off system-wide CPAN install, use sudo deliberately and call cpanm by its full path:

sudo /usr/bin/vendor_perl/cpanm Module::Name

For routine development work, configure local::lib and install modules under your account instead:

sudo pacman -S perl-local-lib
touch ~/.bashrc
grep -qxF 'eval "$(perl -Mlocal::lib=~/perl5)"' ~/.bashrc || printf '%s\n' 'eval "$(perl -Mlocal::lib=~/perl5)"' >> ~/.bashrc
source ~/.bashrc
cpanm Module::Name

Conclusion

Perl is now installed through Arch’s official package manager, with the extra core_perl and vendor_perl paths available for documentation, CPAN, cpanminus, and perlbrew commands. Use pacman packages for system-managed modules, keep CPAN modules user-local when possible, and preview dependency impact before removing the main perl package. For database-backed scripts, pair Perl DBI with SQLite on Arch Linux or PostgreSQL on Arch Linux; for broader Arch-specific Perl behavior, the Arch Wiki Perl page remains the best reference.

Share this guide

Help another Linux user troubleshoot faster

Share this guide with someone troubleshooting Linux systems or saving it for later.

Follow LinuxCapable

Want more LinuxCapable guides in Google?

Add LinuxCapable as a preferred source so Google can show more of our fresh Linux tutorials in Top Stories and From your sources when relevant.

Add LinuxCapable as a preferred source on Google
Search LinuxCapable

Need another guide?

Search LinuxCapable for package installs, commands, troubleshooting, and follow-up guides related to what you just read.

Found this guide useful?

Support LinuxCapable to keep tutorials free and up to date.

Buy me a coffeeBuy me a coffee
Before commenting, please review our Comments Policy.
Formatting tips for your comment

You can use basic HTML to format your comment. Useful tags currently allowed in published comments:

You type Result
<code>command</code> command
<strong>bold</strong> bold
<em>italic</em> italic
<blockquote>quote</blockquote> quote block

Got a Question or Feedback?

We read and reply to every comment - let us know how we can help or improve this guide.

Verify before posting: