Pathologically Eclectic Rubbish Lister | |
PerlMonks |
Re: Conditionally executing different versions of Perlby blokhead (Monsignor) |
on Oct 18, 2006 at 21:46 UTC ( [id://579214]=note: print w/replies, xml ) | Need Help?? |
To the best of my knowledge, you cannot have two levels of shebang-activated programs. So if you run ./test.pl which starts with #!/some/program, then /some/program cannot also be a shebang program.
The solution (or at least a solution) is to call /usr/bin/env, which itself does shebang-emulation, instead of calling your wrapper directly. /path/to/perlwrapper: test.pl: And then executing ./test.pl should work (at least, it did for me). Changing all your scripts to use env in their shebang line is a pain (you cannot just repace /usr/bin/perl with your wrapper), but it's the only way you can emulate nested shebangs. Otherwise, you'd have to make this version-delegation wrapper into a compiled binary. There are also further complications: It appears that if the shebang line doesn't contain the word "perl", then perl itself will try to emulate shebangs and start an infinite loop (re-invoking your version-delegation wrapper). So I got weird results when I first named it "wrapper" instead of "perlwrapper"... blokhead
In Section
Seekers of Perl Wisdom
|
|