I have several different machine architectures and OS (linux 2.4, linux 2.6, solaris, etc.). For each of those, I have several different builds of perl (with threads, without threads, with specific versions of modules, etc.).

I want to have a shell script which will act as a wrapper to choose the right perl version. I know how to figure out the OS and architecture automatically using uname and such. And I will pass special command line arguments to it in order to tell it that I want the threaded perl version or the non-threaded one. Etc.

But I'm getting into trouble.

Let's say the wrapper shell script is at "/usr/local/bin/perl_wrapper". I would really like to do something like this in my perl script:

#! /usr/local/bin/perl_wrapper print "Hello World!\n";

But that doesn't seem to work, because apparently "#!" needs to be followed by a compiled binary, not a shell script?

Okay, I can accept that. So I tried using "env" instead:

#! /usr/bin/env /usr/local/bin/perl_wrapper print "Hello World!\n";

Hey, that works! Great. Now let me just add that "-w" perl switch to it....

#! /usr/bin/env /usr/local/bin/perl_wrapper -w print "Hello World!\n";

Uh-oh! I get this error message:

/usr/bin/env: /usr/local/bin/perl_wrapper -w: No such file or direct +ory

It's like it's trying to find a file called "/usr/local/bin/perl_wrapper -w".

Okay, what do I do now? You can't pass command line arguments when you use /usr/bin/env?

Any help would be appreciated.

Thanks!

--- UPDATE: For some reason, my carriage return characters aren't showing up in the text above? Oy.

--- UPDATE 2: Okay, now it should be formatted better.


In reply to Perl wrapper by weigand

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.