perlbrew
Manage multiple, isolated Perl installations
TLDR
Initialize a perlbrew environment
List available Perl versions
Install/uninstall a Perl version
List perl installations
Switch to an installation and set it as default
Use the system Perl again
List installed CPAN modules for the installation in use
Clone CPAN modules from one installation to another
SYNOPSIS
perlbrew [options] command [arguments]
Common commands:
perlbrew install <perl-version>
perlbrew switch <perl-version>
perlbrew use <perl-version>
perlbrew list
perlbrew help [<command>]
PARAMETERS
install <perl-version>
Compiles and installs a specified Perl version (e.g., perl-5.34.0 or blead) into the perlbrew environment.
switch <perl-version>
Permanently switches the default Perl version for all future shell sessions. Requires shell initialization.
use <perl-version>
Temporarily switches to a specified Perl version for the current shell session only. Does not persist across sessions.
list
Displays a list of all Perl versions currently installed by perlbrew.
available
Shows a list of Perl versions available for installation from perlbrew's official sources.
off
Deactivates perlbrew for the current shell session, reverting to the system's default Perl.
exec [<perl-version>] <command> [<args>]
Executes a specified command or script using a particular perlbrew Perl version, without switching the active version.
lib [<subcommand>]
Manages isolated CPAN library paths (e.g., create, list, use) for different projects or modules within a Perl version.
uninstall <perl-version>
Removes a specified Perl version and its associated files from the perlbrew environment.
self-upgrade
Upgrades the perlbrew tool itself to the latest available version.
help [<command>]
Displays general help information or detailed help for a specific perlbrew command.
DESCRIPTION
perlbrew is a command-line tool that empowers developers to manage multiple, isolated Perl installations in their user directory without requiring root privileges. This makes it an invaluable utility for anyone needing to test code against different Perl versions, handle project-specific dependencies, or develop CPAN modules. Unlike system-wide Perl installations, perlbrew establishes self-contained environments, effectively preventing conflicts and providing unparalleled flexibility. It streamlines the entire process, from compiling and installing various Perl distributions—including development branches and older stable releases—to automatically configuring necessary environment variables. The isolation offered by perlbrew is critical for maintaining system stability while granting developers the freedom to experiment and work with diverse Perl environments. It significantly simplifies the often complex task of managing Perl versions, particularly for module development, testing, and ensuring compatibility across different runtime conditions.
CAVEATS
perlbrew requires a C compiler (e.g., gcc) and other essential build tools to be pre-installed on your system. Some Perl versions may also need additional development libraries (e.g., for zlib, bzip2, OpenSSL) for full functionality. Each installed Perl version consumes significant disk space, typically 100MB-300MB per installation. It is crucial to correctly initialize perlbrew in your shell's startup files (e.g., .bashrc, .zshrc) for switch and other commands to function persistently.
INSTALLATION AND SETUP
To install perlbrew, you typically fetch the installer script:
curl -L https://install.perlbrew.pl | bash
After installation, you must initialize it in your shell by adding the following line to your shell's configuration file (e.g., ~/.bashrc or ~/.zshrc) and then sourcing it:
source ~/perl5/perlbrew/etc/bashrc
This step is crucial for perlbrew to properly set up environment variables and manage your Perl installations.
MODULE MANAGEMENT
When using perlbrew, each Perl installation has its own set of installed CPAN modules. Modules installed with one perlbrew Perl version are not automatically available to others. This isolation is a feature, as it prevents module conflicts across different Perl versions. You can use cpan or cpanm to install modules for the currently active perlbrew Perl.
HISTORY
perlbrew was initially developed by Goro Fuji (gfx) around 2010. Its creation was inspired by similar version managers like rbenv for Ruby and nvm for Node.js. The primary motivation was to provide a flexible and non-invasive way for developers to manage multiple Perl versions without needing root access, addressing common challenges faced in shared hosting environments or when needing to test code against different Perl runtimes. It quickly gained traction within the Perl community and became a de-facto standard for managing development environments, fostering active community contributions and continuous improvement.