"Redirecting" a Shebang Line

I produce Perl CGI scripts for some websites. Some of these scripts were written some time ago when I was using WindowsXP with ActivePerl version 5.8 installed. When I moved over to a Mac a few years ago I installed the same ActivePerl version on the Mac and continued to use it to develop new scripts, changing PATH to point to that version of Perl - the live server that is running these scripts is still on version 5.8.

Everything works fine when I’m working locally with these scripts. However I use MAMP to set up virtual hosts for the various websites so that I can test the scripts on my server before uploading them to the live one. The shebang line in these scripts is the usual /usr/bin/perl one so when I run the scripts on my server it uses the Mac’s inbuilt version of Perl, which for Lion is 5.12. My problem is that I have a module installed on the ActiveState Perl version 5.8 that I’ve not been able to install on the Mac’s 5.12 using CPAN, possibly because although I’ve changed the PATH variable to remove the path to 5.8 it is somehow still getting confused about which version of Perl it is trying to add the module to. I've installed the Developer Tools for Lion so this is not the problem.

I can get round this by changing the shebang line to point to Perl 5.8 but then I’ve got to remember to change it back again before I upload it to the live server. I was wondering if there is any way, by changing the Apache settings or otherwise, of leaving the original shebang line and arranging for my server to use Perl 5.8 rather than the inbuilt 5.12.
RobbieSnrAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Steve BinkCommented:
Rename the perl executables to perl-5.8 and perl-5.12 respectively.  Create a soft link /usr/bin/perl pointing to the version you want to use.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
RobbieSnrAuthor Commented:
Many thanks for this suggestion.

I've just got one question. I suppose that in case the renaming of the inbuilt perl-5.12 caused any problems with the Mac OS I could leave it as it is, just renaming the perl-5.8 one? I'll give this a try.
0
RobbieSnrAuthor Commented:
I've now got this working, many thanks.

I'm very much a beginner as far as bash is concerned and I see that I have to get rid of /usr/bin/perl before I can set up the symbolic link. In fact the /usr/bin/ folder already has a perl5.12 entry. I've set up the link and my shebang line is now redirecting to Perl 5.8 all right. A lot easier than I thought this would be - great.
0
RobbieSnrAuthor Commented:
A very simple solution to my problem.
0
Steve BinkCommented:
And if you ever need to put the 5.12 back into service, just change the soft link to point to the other version.  Good luck!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Apache Web Server

From novice to tech pro — start learning today.

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.