Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to specify which version of perl to use on CentOS

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.

like image 449
DanielBryan Avatar asked Jan 21 '11 21:01

DanielBryan


People also ask

How do I find perl version in Linux?

Type perl -v on a command line to find out which version. ActiveState Perl has binary distributions of Perl for many platforms. This is the simplest way to install the latest version of Perl.

How do I check if perl is installed on Linux?

Checking for a preinstalled Perl version: Many Linux systems have Perl preinstalled in their package. To check if your device is preinstalled with Perl or not, open the terminal using Ctrl+Alt+T .


1 Answers

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
like image 129
Ashley Avatar answered Nov 15 '22 06:11

Ashley