"Redirecting" a Shebang Line
Posted on 2011-10-02
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.