Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

Like hardburn said, the shebang line is interpreted by the system, not Perl. So, if you want to make sure all your systems have the right path set, I would suggest that you have a simple installation script that you run whenever you upload code. Recurse through your root code directory and replace any perl shebangs you find with the right one.

use strict; # duh. use File::Find; find ( sub { open IN, "< $_" || return; # silently discard failed o +pen chomp(my $firstline = <IN>); # read in first line and $firstline =~ /^#!.*perl[\s\Z]/ && do { # check for a shebang $firstline = "#!$^X$'"; # replace with your own she +bang chomp(my @nextlines = <IN>); open OUT, "> $_" && do { # print the file back out map {print OUT $_,$/;} $firstline, @nextlines; close OUT; } # the next bit is a little more concise, but won't replace newli +nes #$firstline = "#!$^X$'$/"; #my @nextlines = <IN>; #open OUT, "> $_" && do { # map {print OUT} $firstline, @nextlines; # close OUT; #} close IN; }, qw| /source/code/directory /another/source/dir |; )

If you call this as perl the special variable $^X will insert the name of your perl executable as 'perl', so run it using /var/binaries/coolest/perl or wherever your executable happens to be.

Note: This was written off-the-cuff, and thoroughly untested. Use this only as a guideline and test it thoroughly before actually using it on any production code. Seriously.

Update: you probably want to write a little shell script on each system, something to the effect of

#!/bin/bash /var/binaries/coolest/perl /usr/local/bin/

That'll simplify your life a little.

Update: as I was cleaning the code a little I realized that this might actually have the happy effect of replacing the newlines in your perl files with your system's $/. I may be wrong, tho.



In reply to Re: #!$var/bin/perl by LAI
in thread #!$var/bin/perl by perlisfun

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, 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, 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.
  • Log In?

    What's my password?
    Create A New User
    [marto]: Good morning all

    How do I use this? | Other CB clients
    Other Users?
    Others about the Monastery: (5)
    As of 2018-04-21 06:38 GMT
    Find Nodes?
      Voting Booth?