| Store | Cart

Re: Questions on porting Perl from Unix to Windows

From: Frank Merrow <fmer...@qualcomm.com>
Thu, 24 Jan 2008 12:10:15 -0800
>Second question:>The UNIX #!/usr/bin/perl notation does not work with Perl scripts on >Windows. How should I code if it is Unix I place "#!/usr/bin/perl" >at the very first line of the script? But, I do not place it at the >first line of code if it is not Unix? How should I do it?

This question is more complicated.  I don't have time to research a 
full answer.  Plus because of some windows nonsense, some user can 
run commands like this:

 >somescript.pl

and some cannot . . . so . . . we wrap all our perl utilities as BAT files.

I offer this *.BAT stub as an answer we have come up with (not the 
only or best - just "a" solution):

@rem = '--*-Perl-*--
@echo off
if "%OS%" == "Windows_NT" goto WinNT
perl -x -S "%0" %1 %2 %3 %4 %5 %6 %7 %8 %9
goto endofperl
:WinNT
perl -x -S %0 %*
if NOT "%COMSPEC%" == "%SystemRoot%\system32\cmd.exe" goto endofperl
if %errorlevel% == 9009 echo You do not have Perl in your PATH.
if errorlevel 1 goto script_failed_so_exit_with_non_zero_val 2>nul
goto endofperl
@rem ';
#!perl
#line 15
Your Perl Code Here
__END__

I hope this helps.

Frank 

Recent Messages in this Thread
Gary Yang Jan 24, 2008 07:15 pm
Frank Merrow Jan 24, 2008 08:04 pm
Frank Merrow Jan 24, 2008 08:10 pm
Frank Merrow Jan 25, 2008 01:10 am
Sébastien Aperghis-Tramoni Jan 24, 2008 09:41 pm
Messages in this thread