using specific perl version

Situation: I had perl 5.8 installed on my linux box, while upgrading it installed perl in
#! /usr/local/bin/perl

but i still have my old perl 5.8 inside
#! /usr/bin/perl

Now i have installed some new perl modules and all gone unders /usr/local/bin/perl

so when i use the following
#! /usr/bin/perl
#! /usr/local/bin/perl

in my perl scripts it looks at the old perl and prompt me that some modules not there. but it's there in the new location!

For the moment, i have the second line as first line... so it's Working!!! but i don't like this way as i have to put the same script  on many site and all sites running the following as first two lines...
#! /usr/bin/perl
#! /usr/local/bin/perl
Now i think the solution would be setting my linux /apache to use the other path for perl, how can i ?

I hope i have cleared  my situation...

Any solution fixing this issue in style will be accepted.

LVL 12
str_kaniAsked:
Who is Participating?
 
ahoffmannConnect With a Mentor Commented:
how about following on your system:

mv /usr/bin/perl{,-old}
ln -s /usr/local/bin/perl /usr/bin/perl

then you can leave your hashbang line as

#! /usr/bin/perl
0
 
cjl7freelance for hireCommented:
Hi,

You can set the path of the lib you want to use...

 use lib LIST;

or

use lib "/usr/local/lib";


Cheers

Jonas
0
 
str_kaniAuthor Commented:
i am new this! can you please tell me where to set this? in the cgi-perl code?

i prefer something to set in the linux machine or apache, because i will not be able to change the code on the development and productions versions, i need to move the dev version to the production. So if i change something in the code for matching my dev enviroment it will affect the production environment also....
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
cjl7freelance for hireCommented:
Sorry,

Yes, you put this in the perl-script that you are running...

the first two lines would look something like this...

#!/usr/local/bin/perl
use lib "/usr/local/lib"
...


// jonas
0
 
str_kaniAuthor Commented:
that's what i have done... but i don't like this way as i have to put the same script  on many site and all sites running the following as first two lines...
#! /usr/bin/perl
#! /usr/local/bin/perl
Now i think the solution would be setting my linux /apache to use the other path for perl, how can i ? I am not interested in an option changing anything in perl script. Please prefer something that can be done through the apache server settings... so that i can use the same script on the demo and productions.

1) is there any way we can switch the updates perl to the path where the current perl running?
0
 
str_kaniAuthor Commented:
can you please tell me what exatcly this will do? and do you really think this will fix the issue? [I am quite new to linux, so please bear with me]
0
 
ahoffmannCommented:
it moves your old perl executable and then makes a symlink to the new executable in place of you old path
then each usage of your old path (/usr/bin/perl) executes the new installed perl (/usr/local/bin/perl), you don't need to change your hashbang lines anymore
0
 
str_kaniAuthor Commented:
Wow, that did that!!!
does this linking last long for ever? or may reset during machine reboot?
0
 
ahoffmannCommented:
no, it's permanent (except you have a special boot script which would change it, which is unusal)
0
 
str_kaniAuthor Commented:
ok, thanks!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.