First, some background.
perlbrew
is a tool to assist with the installation of Perl into a non-standard directory (usually under your home directory).
It also helps you control which Perl installation is used when executing perl
in an interactive shell. Switching between installations is done using perlbrew use
and perlbrew switch
. perlbrew use
only affects the current shell, while perlbrew switch
is more permanent.
$ perl -V:version | $ perl -V:version
version='5.20.0'; | version='5.20.0';
|
$ perlbrew use 5.18.2t | $ perlbrew switch 5.18.2t
|
$ perl -V:version | $ perl -V:version
version='5.18.2'; | version='5.18.2';
|
$ bash -ic 'perl -V:version' | $ bash -ic 'perl -V:version'
version='5.20.0'; | version='5.18.2';
perlbrew off
is used to revert to using the system Perl, but it's temporary like perlbrew use
. Is there a way to revert to the system Perl with the permanency of perlbrew switch
?
perlbrew is a tool to manage multiple perl installations in your $HOME directory (or wherever you specify). They are completely isolated perl universes, and has no relationship with system perl, or between each others. This approach has many benefits: No need to run sudo to install CPAN modules, any more.
INSTALLATION. After that, perlbrew installs itself to ~/perl5/perlbrew/bin , and you should follow the instruction on screen to modify your shell rc file to put it in your PATH. The installed perlbrew command is a standalone executable that can be run with system perl. The minimum required version of system perl is 5.8 ...
Install Perlbrew You can also install the App::perlbrew module from CPAN with cpan App::perlbrew . Or you can download and run the installation script at install.perlbrew.pl. To begin using Perlbrew, run perlbrew init .
To have perlbrew
manage an installation of perl
that wasn't installed by perlbrew
, pick a name ("system
" in my example) and create a link to its bin
directory as follows:
cd "${PERLBREW_ROOT:-$HOME/perl5/perlbrew}"
mkdir perls/system
ln -s /usr/bin perls/system/bin
It will now appear in perlbrew list
$ perlbrew list
...
system (5.10.1)
5.18.2t
* 5.20.0t
...
And you'll be able to use perlbrew use
and perlbrew switch
.
$ perl -V:version
version='5.20.0';
$ perlbrew switch system
$ perl -V:version
version='5.10.1';
$ bash -ic 'perl -V:version'
version='5.10.1';
This works best with installations that have the same installbin
, installvendorbin
(if applicable) and installsitebin
directories, as returned by
perl -V:'install.*bin'
By the way, a similar approach can be used to create aliases for perlbrew
installs. For example,
ln -s 5.26.1 perls/5.26 # Point to the latest release of a version.
ln -s 5.26.1 perls/project_name # Point to the install used by a project.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With