How to specify which version of perl to use on CentOS

DanielBryan picture DanielBryan · Jan 21, 2011 · Viewed 27.3k times · Source

I am running CentOS 5.4 which only has version 5.8 of perl available by default, and I have a program which requires perl 5.10, so I compiled perl 5.10 on CentOS. How do I specify which perl I want to run the program with because the perl command uses 5.8 by default.

Answer

Ashley picture Ashley · Jan 22, 2011

I add my voice to recommending against messing with the system perl at all.

No one mentioned App::perlbrew yet. It allows you to have several versions of Perl and switch between them easily. This can be done manually of course but it's much easier to have this tool to do it for you; from the Pod–

# Install some Perls
perlbrew install perl-5.12.2
perlbrew install perl-5.8.1
perlbrew install perl-5.13.6

# See what were installed
perlbrew list

# Switch perl in the $PATH
perlbrew switch perl-5.12.2
perl -v

# Switch to another version
perlbrew switch perl-5.8.1
perl -v

# Switch to a certain perl executable not managed by perlbrew.
perlbrew switch /usr/bin/perl

# Or turn it off completely. Useful when you messed up too deep.
perlbrew off

# Use 'switch' command to turn it back on.
perlbrew switch perl-5.12.2