Barring some special circumstances you should really be hardcoding the perl you are using.

Why, might I ask? I've scratched my head over this for several minutes and I simply can't think of a good reason for doing this, except in the unusual case where you have multiple incompatible Perl interpreters installed at the same time.

I certainly don't see how it could be a security thing. If someone's capable of adding a malicious perl binary to the $PATH of someone with superuser privileges, then the machine is probably rooted already.

And even if there are cross-platform compatibility issues that still doesn't justify leaving it up to your PATH because you can detect the system you are on and then run a hardcoded perl from within your wrapper shell script.

I'm not sure why you assume there's a wrapper shell script. I've never had any desire to use such a thing. #! /usr/bin/env perl works just fine.

Where you have a heterogeneous set of environments, the last thing you want is a fragile script that lists half a dozen or more different magic filenames, and breaks if you upgrade a system. One of the nice things about Perl is that it lets you get away from shell scripts, which are a nightmare to make portable!

And that's without even getting into the situation I'm commonly in, where I don't know what systems my scripts are going to run on. Sure, I could write a fragile shell script, and then when someone wants to run the script on Cygwin I could add another special case, and then when someone wants to run it on Solaris I could add yet another special case... or, you know, I could just put #! /usr/bin/env perl and it would just work on all the most common platforms, letting me reserve special-case handling for actual special cases.


In reply to Re^2: #!/usr/bin/perl vs. -*- perl -*- by Porculus
in thread #!/usr/bin/perl vs. -*- perl -*- by why_bird

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.