Install Perlbrew¶
Perlbrew is a tool to manage multiple perl installations in your home directory. They are completely isolated perl installations. See the perlbrew homepage is at https://perlbrew.pl.
Install Perlbrew¶
Run the following command to download and install perlbrew:
curl -L https://install.perlbrew.pl | bash
$ curl -L https://install.perlbrew.pl | bash
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 1410 100 1410 0 0 1284 0 0:00:01 0:00:01 --:--:-- 1284
Installing perlbrew
Using Perl </usr/bin/perl>
perlbrew is installed: ~/perl5/perlbrew/bin/perlbrew
perlbrew root (~/perl5/perlbrew) is initialized.
Append the following piece of code to the end of your `~/.bash_profile and start a
new shell, perlbrew should be up and fully functional from there:
source ~/perl5/perlbrew/etc/bashrc
Simply run `perlbrew` for usage details.
Happy brewing!
Done.
Init and Edit .bashrc¶
Now according to the install instructions you need to do a “once off”, perlbrew init
.
$ perlbrew init
Perlbrew environment initiated, required directories are created under
~/perl5/perlbrew
Paste the following line(s) to the end of your ~/.bashrc and start a
new shell, perlbrew should be up and fully functional from there:
source ~/perl5/perlbrew/etc/bashrc
For further instructions, simply run `perlbrew` to see the help message.
Enjoy perlbrew at $HOME!
and as it suggested above you can add the source line to your ~/.bashrc file. If you do not wish to add this line to your .bashrc then you can just run that line before you wish to use your Perl brew either at the command line or in your PBS scripts i.e.
$ source ~/perl5/perlbrew/etc/bashrc
Note: If you install another local perl system like “Linux Brew” you probably do not want to have this source line in your ~/.bashrc.
Example, Installing a Perlbrew Perl Instance¶
List what perl instances are available. Note that odd numbered perl versions like perl-5.27.6 are development versions! You should use an even numbered version like perl-5.34.0.
$ perlbrew available
perl-5.35.3
perl-5.34.0
perl-5.32.1
perl-5.30.3
perl-5.28.3
perl-5.26.3
perl-5.24.4
perl-5.22.4
perl-5.20.3
perl-5.18.4
perl-5.16.3
perl-5.14.4
perl-5.12.5
perl-5.10.1
perl-5.8.9
perl-5.6.2
perl5.005_03
perl5.004_05
# cperl
cperl-5.30.0-RC1
cperl-5.30.0
Lets install perl-5.34.0 – the latest stable release.
Note
If there are problems the install instructions say to use perlbrew -v install perl-xx.yy.z
but I found that the install would still fail. The suggestion to use force i.e.
perlbrew --force install perl-5.34.0
also might fail. The solution is to use --notest
.
See reference at end.
$ perlbrew install perl-5.34.0 --notest
Fetching perl-5.34.0 as /shared/homes/xxxxxx/perl5/perlbrew/dists/perl-5.34.0.tar.gz
Installing /shared/homes/xxxxxx/perl5/perlbrew/build/perl-5.34.0 into
~/perl5/perlbrew/perls/perl-5.34.0
......
This could take a while. You can run the following command on another shell to
track the status:
tail -f ~/perl5/perlbrew/build.log
Installed /shared/homes/xxxxxx/perl5/perlbrew/build/perl-5.34.0 as perl-5.34.0 successfully.
Run the following command to switch to it.
perlbrew switch perl-5.34.0
The install really does take a long time ..... Once it is finished you can list what perls you have installed with:
$ perlbrew list
perl-5.34.0
perl-5.12.3
$
General Usage¶
To use an installed perl just type perlbrew switch perl_version
:
$ which perl
/usr/bin/perl
$ perlbrew switch perl-5.34.0
$ which perl
~/perl5/perlbrew/perls/perl-5.34.0/bin/perl
$
To return to your original perl use perlbrew off
$ perlbrew off
perlbrew is switched off. Please exit this shell and start a new one to make it effective.
To immediately make it effective, run this line in this terminal:
exec /bin/bash
$ which perl
/usr/bin/perl
$
If you just want to play with a version of Perl in the current shell, just use this command:
perlbrew use perl-5.34.0
Typing perlbrew list
will indicate which perl is currently in effect.
Remember to get help just type: perlbrew help
Installing Perl Modules within Perlbrew¶
We will need to install cpanm to manage your perl modules. Perlbrew comes with an
option to do that for us. This just installs perl5/perlbrew/bin/cpanm
.
$ perlbrew install-cpanm
Useful Things¶
Set a useful Bash Prompt
In your .bashrc
set your PS1 variable like this:
PS1="`perlbrew list | grep \* | tr -d ' '`$ "
Now your bash prompt will show the version of Perl that is in effect.
perl-5.34.0$
References¶
Switching to the system Perl using perlbrew
How I setup my Debian server to run perl 5.13.1 with perlbrew