Q:

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.

A:

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

A:

The first line of the program file should reference the perl binary you wish to use:
e.g.
#!/usr/bin/perl

You may also want to change your PATH variable so that the directory your perl 5.10 binary is in is listed prior to the 5.8 binary directory.
e.g.
export PATH=/path/to/perl/5.10:$PATH

A:

I like to make symbolic links to my different perl executables in /usr/local/bin:
$ [sudo] ln -s /path/to/perl5.10.1.exe /usr/local/bin/perl510
$ [sudo] ln -s /path/to/perl5.13.8.exe /usr/local/bin/perl513
$ ... etc. ...
$ # and just for completeness
$ ln -s /usr/bin/perl /usr/local/bin/perl58

and then just invoke:
$ perl510 script_to_use_with_v5.10.pl

