LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How to Change which Perl binary to use (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-change-which-perl-binary-to-use-733292/)

akshayk 06-16-2009 05:08 AM

How to Change which Perl binary to use
 
Hi,

I have two perl binaries .. one in /usr/local/bin and another in $HOME/bin/perl5/bin

I want to use the second perl binary as default. I have added the path of the second perl5 bin directory to $PATH. But when I am doing 'which perl' it is still picking up from /usr/local/bin....

Can someone tell me how to change which default binary to pick ??

jamescondron 06-16-2009 05:09 AM

Question, what is the difference between the two?

akshayk 06-16-2009 05:21 AM

The two binaries are of different versions.. I needed the latest version. I am running a script which uses the default perl binary... I can't change the script... What I want is to pick this new perl binary instead of the default one...

I also can't change the original Binary(in /usr/local/bin)

jamescondron 06-16-2009 05:23 AM

If you change versions, you may break the dependencies. And why can't you change the script? Just edit the shabang.

Incidentally, what have your tried before this? Because google is full of suggestions and answers:
http://www.google.co.uk/search?clien...utf-8&oe=utf-8

Su-Shee 06-16-2009 06:58 AM

Just add an alias in your .alias

alias perl="/home/you/bin/perl"

Wim Sturkenboom 06-16-2009 07:28 AM

You can apply the following to your perl installations:

I have two versions of tcltk installed on my system. Both binaries live in (in my case) /usr/bin/
Code:

wim@desktop1:~$ ls -l /usr/bin/tclsh*
lrwxrwxrwx 1 root root  23 2007-07-17 14:21 /usr/bin/tclsh -> /etc/alternatives/tclsh
-rwxr-xr-x 1 root root 3704 2008-02-25 09:20 /usr/bin/tclsh8.4
-rwxr-xr-x 1 root root 3704 2008-04-22 21:22 /usr/bin/tclsh8.5
wim@desktop1:~$

The standard one is pointed to by tclsh which is linked to /etc/alternatives/tclsh which in turn (not shown) is linked to /usr/bin/tclsh8.4. If I want to use (from the command line) tclsh8.4, I can either type tclsh or tclsh8.4 . If I want to use tclsh8.5, I type tclsh8.5 . To change the default (8.4 to 8.5) one can simply change the symbolic link.
If I want to use it in a script, I'll have to change the shabang as mentioned by jamescondron.
Code:

#! /usr/bin/tclsh
Use /usr/bin/tclsh if you want the default (whichever it is), /usr/bin/tclsh8.4 if you want tclsh8.4 specifically and /usr/bin/tclsh8.5 if you want tclsh8.5 specifically.

vimmex 06-16-2009 12:38 PM

Have you tried placing your $HOME/bin/perl5/bin path before /usr/local/bin?

akshayk 06-17-2009 12:25 AM

I have put $HOME/bin/perl5/bin before /usr/local/bin and right now I have a strange confusion...

Here are the version numbers...
/usr/local/bin/perl - 5.6.1
$HOME/bin/perl5/bin/perl - 5.8.4

Now when I do 'which perl' it is pointing to /usr/local/bin/perl
but when I do 'perl --version' it is showing as 5.8.4... Donno the reason..

Wim Sturkenboom 06-17-2009 05:59 AM

Try which -a.


All times are GMT -5. The time now is 07:51 PM.