Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

Re: Can I write a transparent shell wrapper to start the correct build of Perl?

by Tanktalus (Canon)
on Oct 11, 2013 at 16:50 UTC ( #1057922=note: print w/replies, xml ) Need Help??

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:

#!/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;
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.

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
    Thanks a ton for this post! I applied the same technique and was successful!. It made my day. :-)

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1057922]
[Eily]: choroba but does $name = $1 solve the issue ?
[Eily]: if so, most subs start with my (VARIABLES) = @_ anyway
[moritz]: for short subs, I sometimes let them work on $_[0] directly
[Eily]: moritz but that should be fine unless you modify them

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (7)
As of 2018-02-22 17:24 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (296 votes). Check out past polls.