At 07:29 PM 6/12/01 -0400, Lupino, Joseph (Exchange) wrote:
>In perl, for unix, the header of a script has the path to perl.
>For example:
>
> #!/usr/local/bin/perl
I hope that you'd rather use
#!/usr/local/bin/perl -w
>In a perl script for NT, one might invoke perl by doing:
>
> #!C:\perl\perl.exe
>
>If I wish to write a single perl script that will work on both unix and NT
>without modification, how can you do it?
>
>For example is this acceptable:
>
> #!/usr/local/bin/perl
> #!C:\perl\perl.exe
It would work, but not for the reason you're thinking (the second line is
interpreted purely as a comment).
The path component is ignored on NT, because the OS has already found Perl
by the time it opens the file. So just use the path you need for Unix, and
it'll work fine on NT also.
If your perl might live in different places on Unix, there's a gnarly
construction in 'perldoc perlrun' that will find it:
#!/usr/bin/perl
eval 'exec /usr/bin/perl -wS $0 ${1+"$@"}'
if $running_under_some_shell;
--
Peter Scott
Pacific Systems Design Technologies
http://www.perldebugged.com