Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Install another Perl in Linux?

In our development environment, another team is using default Perl. So we shouldn't touch it. How do I install another Perl? How do I install Perl modules using CPAN?

like image 268
Naghaveer R Avatar asked Feb 24 '14 06:02

Naghaveer R


1 Answers

anyenv is a great platform to install local versions of all the great open environments, Perl included:

$ git clone https://github.com/riywo/anyenv ~/.anyenv
$ echo 'export PATH="$HOME/.anyenv/bin:$PATH"' >> ~/.bash_profile
$ echo 'eval "$(anyenv init -)"' >> ~/.bash_profile  # change profile if needed
$ exec $SHELL -l

This will set up anyenv. From here, you will install plenv, the Perl environment tool. Each of the environment tools allows you to manage that languages different installed versions.

$ anyenv install plenv

Now we can work with the plenv tool...

List available Perl versions:

$ plenv install --list

Install the Perl 5.18.2 binary:

$ plenv install 5.18.2 -Dusethreads

Change global default Perl to 5.18.2:

$ plenv global 5.18.2

Change local project Perl to 5.18.2:

$ plenv local 5.18.2

Run this command after installing a CPAN module, containing an executable script:

$ plenv rehash

Install cpanm to the current Perl:

$ plenv install-cpanm

Install any modules you need from CPAN with

$ cpanm JSON

I use Carton to manage dependencies within a project and recommend you take a look at it.

Now that you have anyenv, remember you can explore different versions of other languages too. anyenv is a priceless tool.

$ anyenv install --list
Available **envs:
  denv
  jenv
  luaenv
  ndenv
  phpenv
  plenv
  pyenv
  rbenv
like image 119
spleck Avatar answered Sep 20 '22 22:09

spleck