in reply to Can I write a transparent shell wrapper to start the correct build of Perl?
I know this is an old thread, and I know I've already responded to it, but, since then, I've come up with and am using a completely different method for dealing with situations similar to this.
I have a "dev_perl" script. Written in perl. And I put that into the #! line. (Well, I actually have it in the PATH and use #!/bin/env dev_perl, but close enough.)
So, this dev_perl script is something like this:
In my case, I actually determine which workspace I'm in, version of our product, map that to the desired perl level, and look up where that level is from another file. And then I basically exec that version with all the original parameters. I also allow that if the command line has something that looks like /^5\.\d+\.\d+$/ as the first parameter, I shift that off and use it as the version instead of trying to detect the version. I could, instead, look for the command to run (which might not be the first parameter - I often use "dev_perl -d $tool @params" to debug stuff), and try to see if there is a "use 5.10.1" or some such in there to determine what level to run, I suppose, but I haven't found the need yet.#!/usr/bin/perl my $os = $^O; # You may need something more complex - I do my $version = '5.10'; # I need more complex than this exec "/nfs/perl/$version/$os/bin/perl", @ARGV;
Note how this script uses /usr/bin/perl - which should exist on all unix-like platforms. And the main reason for all this extra overhead? Because doing the complex stuff is far easier in perl than shell.
|Replies are listed 'Best First'.|
Re^2: Can I write a transparent shell wrapper to start the correct build of Perl?
by Anonymous Monk on Jun 23, 2015 at 17:03 UTC