2.13.2015

Install different versions of Perl on Linux using Perlbrew

Got from here and here. What is perlbrew.
1. Install perfbrew
$ curl -kL http://install.perlbrew.pl | bash

2. Modify .bashrc and add:
source ~/perl5/perlbrew/etc/bashrc

3. Initialize
$ perlbrew init

4. Select mirror
$ perlbrew mirror

5. See what's available
$ perlbrew available
  perl-5.20.1
  perl-5.18.4
  perl-5.16.3
  perl-5.14.4

6. Install perls
$ perlbrew install perl-5.20.1  # did not work for Centos 6.5
$ perlbrew --notest install perl-5.20.1

7. See what were installed
$ perlbrew list

8. Swith to an installation and set it as default
$ perlbrew switch perl-5.20.1

9. Temporarily use another version only in current shell.
$ perlbrew use perl-5.20.1
$ perl -v

10. Or turn it off completely. Useful when you messed up too deep. Or want to go back to the system Perl.
$ perlbrew off

11. Use 'switch' command to turn it back on.
$ perlbrew switch perl-5.20.1

12. Exec something with all perlbrew-ed perls
$ perlbrew exec -- perl -E 'say $]'

13. Install cpanm
$ perlbrew install-cpanm

14. Install cpan modules
$ cpanm install File::Copy::Recursive XML::Simple etc

No comments:

Post a Comment