In our installation, we have perl installed as a multi-platform setup:
/net/tools/perl/perl-5.8.8/bin/perl (wrapper) /net/tools/perl/perl-5.8.8/lib/... /net/tools/perl/perl-5.8.8/sparc/bin/perl /net/tools/perl/perl-5.8.8/i386/bin/perl /net/tools/perl/perl-5.8.8/linux/bin/perl
The perl wrapper is a bourne shell script that runs "uname" to determine what architecture one is in, and then does an exec to the binary specific perl in either sparc (Solaris), i386 (Solaris), or linux. Scripts that use this installation, need to have custom shebang ("#!") headers, so that the script will run on any of the platforms. We're using this setup:
#!/bin/sh -- # -*- perl -*- eval 'exec /net/tools/perl/perl-5.8.8/bin/perl -xw $0 ${1+"$@"}' if 0;
Using this format, our scripts can run without modification on any of our three platforms. There are numerous reasons why we've settled on this setup. Without Linux support, the header is simpler, and can just be as follows (Note the "perl" magic line can be added behind the bourne shell shebang, and the "-x" is not needed.):
#!/bin/sh -- # -*- perl -*- eval 'exec /net/tools/perl/perl-5.8.8/bin/perl -w $0 ${1+"$@"}' if 0;
The Linux bourne shell however doesn't allow arguments, so the "perl" magic string has to be commented as line #2, and then we have to add "-x" so that perl can figure out where it needs to start executing perl correctly. (Read perlrun for more information.) What I'm writing for advice and help with, is that when we try to debug a script with this header, the debugging structure croaks:
% myscript.pl
will run just fine. But to debug, we try this:
% /net/tools/perl/perl-5.8.8/linux/bin/perl -d myscript.pl
This doesn't work. It starts the debugger OK, but then tries to open "-d" as if it's a file. Here's the code:
% cat test-debug.pl #!/bin/sh #!-*- perl -*- eval 'exec /net/tools/perl/perl-5.8.8/bin/perl -wx $0 ${1+"$@"}' if 0; print "$^X\n"; print "HI THERE\n"; exit; % /net/tools/perl/perl-5.8.8/bin/perl -d test-debug.pl Loading DB routines from perl5db.pl version 1.28 Editor support available. Enter h or `h h' for help, or `man perldebug' for more help. -d: bad option(s)
This fails the same on all platforms.

So, any advice on how to improve this setup?

Here are some additional points:
So, just curious if anyone in the Monastery has some special sauce that works for both Linux and Solaris... thanks! Cadphile...

In reply to multi-platform perl header for linux and solaris 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.