LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-16-2009, 05:08 AM   #1
akshayk
LQ Newbie
 
Registered: Jun 2009
Posts: 3

Rep: Reputation: 0
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 ??
 
Old 06-16-2009, 05:09 AM   #2
jamescondron
Member
 
Registered: Jul 2007
Location: Scunthorpe, UK
Distribution: Ubuntu 8.10; Gentoo; Debian Lenny
Posts: 961

Rep: Reputation: 69
Question, what is the difference between the two?
 
Old 06-16-2009, 05:21 AM   #3
akshayk
LQ Newbie
 
Registered: Jun 2009
Posts: 3

Original Poster
Rep: Reputation: 0
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)
 
Old 06-16-2009, 05:23 AM   #4
jamescondron
Member
 
Registered: Jul 2007
Location: Scunthorpe, UK
Distribution: Ubuntu 8.10; Gentoo; Debian Lenny
Posts: 961

Rep: Reputation: 69
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
 
Old 06-16-2009, 06:58 AM   #5
Su-Shee
Member
 
Registered: Sep 2007
Location: Berlin
Distribution: Slackware
Posts: 509

Rep: Reputation: 41
Just add an alias in your .alias

alias perl="/home/you/bin/perl"
 
Old 06-16-2009, 07:28 AM   #6
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Slackware 10.1/10.2/12, Ubuntu 12.04, Crunchbang Statler
Posts: 3,786

Rep: Reputation: 282Reputation: 282Reputation: 282
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.
 
Old 06-16-2009, 12:38 PM   #7
vimmex
LQ Newbie
 
Registered: Nov 2008
Location: Mexico
Distribution: Arch Linux
Posts: 10

Rep: Reputation: 0
Have you tried placing your $HOME/bin/perl5/bin path before /usr/local/bin?
 
Old 06-17-2009, 12:25 AM   #8
akshayk
LQ Newbie
 
Registered: Jun 2009
Posts: 3

Original Poster
Rep: Reputation: 0
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..
 
Old 06-17-2009, 05:59 AM   #9
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Slackware 10.1/10.2/12, Ubuntu 12.04, Crunchbang Statler
Posts: 3,786

Rep: Reputation: 282Reputation: 282Reputation: 282
Try which -a.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How Can I convert Hex to Binary in a perl script telecom_is_me Programming 18 10-11-2010 04:34 PM
Replacing binary data containing & using perl in HPUX 11.11 adk Programming 8 10-06-2008 03:58 AM
Converting perl to Binary DanTaylor Programming 3 02-02-2006 08:57 PM
calling a c++ binary inside a perl script Blue_muppet Programming 3 08-28-2004 11:31 PM
perl NET::FTP binary mode lackluster Programming 5 07-18-2002 06:30 PM


All times are GMT -5. The time now is 04:34 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration