in reply to #!$var/bin/perl
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 thisscript.pl the special variable $^X will insert the name of your perl executable as 'perl', so run it using /var/binaries/coolest/perl thisscript.pl 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/thisscript.pl
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.
LAI
__END__
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: #!$var/bin/perl
by IlyaM (Parson) on Mar 13, 2003 at 17:31 UTC | |
by LAI (Hermit) on Mar 13, 2003 at 17:53 UTC |