It actually *does* work beautifully if you call perl from the commandline. In that case, you're just calling the shell script, which exec's to the appropriate perl binary.

It's the case of the hundred of perl scripts/tools which invoke the perl interpreter in the top line. The unix kernel performs magic to figure out how to handle the file you name there, or whether that file is a shell script, and then which shell interpreter to call.

And it does seem to work if I call the perl script/tool as you say:

   <perlpath>/bin/perl myperlscript.pl
This seems to work. Actually, if the tool is called through a wrapper, and that tool wrapper calls the tool as above, that will work! I think this is the solution!!
## my tool:
   perl-script-to-do-some-work.pl -> .multi-perl588-wrapper
## the wrapper finds the latest released version of the
## tool, and does an exec:
   PERL=<perlpath>/bin/perl
   EXE=<tool-root>/<tool-version>/bin/<tool>
   exec $PERL $EXE "$@"
## that $PERL does exec, if on i386:
   exec <perlpath>/i386/bin/perl
## if on sparc
   exec <perlpath>/sparc/bin/perl
The key to this is to make sure the tool is wrapped, so that the wrapper can get both the tool release version, and also call it using an explicit perl override.

Hey, that was the ticket!! All our tools are wrapped anyway, so this will work perfectly!!!

Monks rock!


In reply to Re^2: using "#!/<perlpath>/bin/perl" to exec a shell script? by cadphile
in thread using "#!/<perlpath>/bin/perl" to exec a shell script? by cadphile

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.