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 add the source line to your ~/.bashrc file.

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.26.1.

$ perlbrew available
  perl-5.27.6
  perl-5.26.1
  perl-5.24.3
  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_04
  perl5.004_05

Lets install perl-5.26.1

The install instruction say to use perlbrew -v install perl-xx.yy.z but I found that the install would fail. The suggestion to use force i.e. perlbrew --force install perl-5.26.1 also fails. Use --notest. See reference at end.

$ perlbrew install perl-5.26.1 --notest

Fetching perl-5.26.1 as /shared/homes/xxxxxx/perl5/perlbrew/dists/perl-5.26.1.tar.gz
Installing /shared/homes/xxxxxx/perl5/perlbrew/build/perl-5.26.1 into 
~/perl5/perlbrew/perls/perl-5.26.1
......

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.26.1 as perl-5.26.1 successfully. 
Run the following command to switch to it.

    perlbrew switch perl-5.26.1

You can list what perls you have installed with:

$ perlbrew list
  perl-5.16.3
  perl-5.26.1
  * /usr/bin/perl (5.10.1)
$

General Usage

To use an installed perl just type perlbrew switch perl_version:

$ which perl
/usr/bin/perl

$ perlbrew switch perl-5.26.1
$ which perl
~/perl5/perlbrew/perls/perl-5.26.1/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.26.1

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 \* | sed s/'* '//`$ "

Now your bash prompt will show the version of Perl that is in effect.

perl-5.20.1$

References

Trouble Installing New Version of Perl Using Perlbrew

References for Perlbrew:

http://perlbrew.pl/ and https://metacpan.org/pod/distribution/App-perlbrew/bin/perlbrew

http://stackoverflow.com/questions/25188575/switching-to-the-system-perl-using-perlbrew
http://blogs.perl.org/users/aevar_arnfjor_bjarmason/2010/06/how-i-setup-my-debian-server-to-run-perl-5131-with-perlbrew.html

Alternatives to Perl Brew: plenv

This is custom footer