LinuxQuestions.org
Register a domain and help support LQ
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 09-15-2011, 06:59 AM   #1
graziano1968
Member
 
Registered: Sep 2004
Posts: 223

Rep: Reputation: 30
which and perl


Hello

I have perl installed in 2 locations

/usr/bin/perl /usr/local/bin/perl

When I execute
# which perl

I receive this
/usr/local/bin/perl

What to do if I want to make default /usr/bin/perl (instead of
/usr/local/bin/perl) ?

Thank you!
 
Old 09-15-2011, 07:09 AM   #2
kakaka
Member
 
Registered: Sep 2003
Posts: 382

Rep: Reputation: 87
If I'm understanding your situation correctly, if you just wish to have someone find one perl instead of the other when they type perl at a command prompt, you should be able to switch the positions of the two perl's directories in the PATH variable.
 
Old 09-15-2011, 07:15 AM   #3
graziano1968
Member
 
Registered: Sep 2004
Posts: 223

Original Poster
Rep: Reputation: 30
Quote:
Originally Posted by kakaka View Post
If I'm understanding your situation correctly, if you just wish to have someone find one perl instead of the other when they type perl at a command prompt, you should be able to switch the positions of the two perl's directories in the PATH variable.
not exactly, I have perl installed in 2 locations

/usr/bin/perl and /usr/local/bin/perl


These are 2 different perl versions

If I execute

# perl -v

the os uses /usr/local/bin/perl -v , while I want it uses /usr/bin/perl -v

How it is possible please ?
 
Old 09-15-2011, 07:16 AM   #4
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen, DK
Distribution: pclos2016, Slack14.1 Deb Jessie, + 50+ other Linux OS, for test only.
Posts: 16,276

Rep: Reputation: 3156Reputation: 3156Reputation: 3156Reputation: 3156Reputation: 3156Reputation: 3156Reputation: 3156Reputation: 3156Reputation: 3156Reputation: 3156Reputation: 3156
It's a mistake to have two times perl in your PATH.

The easy solution :
Rename the perl in /usr/local/bin/ to perl510 (Or whatever version it is.)
Using perl510 : 'perl510 <file>'.

The usual way of creating an extra "local perl" :
Configure with e.g. --prefix=/usr/local/perl510/ , at build time.

..
 
Old 09-15-2011, 07:22 AM   #5
graziano1968
Member
 
Registered: Sep 2004
Posts: 223

Original Poster
Rep: Reputation: 30
Quote:
Originally Posted by knudfl View Post
It's a mistake to have two times perl in your PATH.

The easy solution :
Rename the perl in /usr/local/bin/ to perl510 (Or whatever version it is.)
Using perl510 : 'perl510 <file>'.

The usual way of creating an extra "local perl" :
Configure with e.g. --prefix=/usr/local/perl510/ , at build time.

..

ok however I know there is a way to tell to linux which I want use between
/usr/bin/perl and /usr/local/bin/perl , and the current selected is returned by "which perl"
command. The problem is that I can't remember how to do it , anyone can help me to remember the way ?
 
Old 09-15-2011, 07:28 AM   #6
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen, DK
Distribution: pclos2016, Slack14.1 Deb Jessie, + 50+ other Linux OS, for test only.
Posts: 16,276

Rep: Reputation: 3156Reputation: 3156Reputation: 3156Reputation: 3156Reputation: 3156Reputation: 3156Reputation: 3156Reputation: 3156Reputation: 3156Reputation: 3156Reputation: 3156
Use the full path :

which /usr/bin/perl
which /usr/local/bin/perl

/usr/bin/perl -v
/usr/local/bin/perl -v

.
 
Old 09-15-2011, 09:27 AM   #7
anomie
Senior Member
 
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Scientific Linux, Debian, Fedora
Posts: 3,935
Blog Entries: 5

Rep: Reputation: Disabled
Quote:
Originally Posted by graziano1968
ok however I know there is a way to tell to linux which I want use between
/usr/bin/perl and /usr/local/bin/perl , and the current selected is returned by "which perl"
command. The problem is that I can't remember how to do it , anyone can help me to remember the way ?
Either fix your PATH, as mentioned -

Code:
export PATH=/bin:/usr/bin:/usr/local/bin
---

Or set up an alias -

Code:
alias perl='/usr/bin/perl'
Either can be added to your user's bash(1) initialization files.
 
Old 09-15-2011, 10:12 AM   #8
graziano1968
Member
 
Registered: Sep 2004
Posts: 223

Original Poster
Rep: Reputation: 30
Quote:
Originally Posted by anomie View Post
Either fix your PATH, as mentioned -

Code:
export PATH=/bin:/usr/bin:/usr/local/bin
---

Or set up an alias -

Code:
alias perl='/usr/bin/perl'
Either can be added to your user's bash(1) initialization files.
there is another way , shame on me which I do not remember it .
 
Old 09-15-2011, 10:55 AM   #9
anomie
Senior Member
 
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Scientific Linux, Debian, Fedora
Posts: 3,935
Blog Entries: 5

Rep: Reputation: Disabled
Well, now you've been given four ways to solve the problem in this thread. When you remember your fifth way, you can start doing it, and free yourself from the shame. Until then, you have a fix.
 
Old 09-15-2011, 11:29 AM   #10
graziano1968
Member
 
Registered: Sep 2004
Posts: 223

Original Poster
Rep: Reputation: 30
yes ..

BTW "which" command exists right for this , it returns you the location used by a command (between 2 or more).
There is also a command which permit to choose which command should use the OS when there are 2 or more.
I know "alias" , however I am sure it was not the solution .
 
Old 09-15-2011, 11:33 AM   #11
anomie
Senior Member
 
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Scientific Linux, Debian, Fedora
Posts: 3,935
Blog Entries: 5

Rep: Reputation: Disabled
Quote:
Originally Posted by graziano1968
BTW "which" command exists right for this , it returns you the location used by a command (between 2 or more).
Code:
$ which -a perl
 
  


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
Print output of a script to screen using Perl/Multiple installation of Perl Modules metallica1973 Linux - General 1 02-17-2011 06:59 PM
LXer: Installing Eclipse, the Epic Perl plugin and my first Perl GUI program LXer Syndicated Linux News 0 05-08-2009 07:41 PM
RHEL4u2 perl localtime() call issues (perl & glibc) Brad.Scalio@noaa.gov Linux - Enterprise 3 01-23-2007 10:27 PM
perl(Cwd) perl(File::Basename) perl(File::Copy) perl(strict)....What are those? Baldorg Linux - Software 1 11-09-2003 09:09 PM
chrooting apache v2 (php, ssl, perl support) ; perl configuration markus1982 Linux - Security 3 01-26-2003 07:15 PM


All times are GMT -5. The time now is 08:03 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