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.
相关问题
- Is shmid returned by shmget() unique across proces
- $ENV{$variable} in perl
- how to get running process information in java?
- Error building gcc 4.8.3 from source: libstdc++.so
- Why should we check WIFEXITED after wait in order
set your PATH environment variable to point to your new perl executable. For instance
I like to make symbolic links to my different perl executables in
/usr/local/bin
:and then just invoke:
The first line of the program file should reference the perl binary you wish to use: e.g.
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.
BTW, The perlbrew package is available for installation from the EPEL repository for CentOS 5.x. I tried to install just this rpm initially but it has a number of dependencies so I opted to add the EPEL repository to my list of yum repos on my box.
solution has two parts ... first edit myscript.pl which wants specific version
above has no impact on normal executions of the script ... when you want above myscript.pl to use a specific perl version create a wrapper script which contains
this way other invocations of the script remain unchanged and they just use default perl whereas launcher wrapper script executes same myscript.pl script with chosen perl version
There is a tool called alternatives that was designed to deal effectively with exactly this kind of problem. It basically gives you an easy way of switching between different version of applications by manipulating symbolic links in e.g. your bin directories.
Say "man alternatives" in a terminal (or yum install alternatives, if you don't have it installed).