> -----Original Message-----
> From: activeperl-boun...@listserv.activestate.com [mailto:activeperl-
> boun...@listserv.activestate.com] On Behalf Of Michael Ludwig
> Sent: 25 February 2012 10:33
> To: activeperl@listserv.activestate.com
> Subject: BAT scripts in bin\ directory
>
> There are lots of BAT scripts in the distribution's bin\ directory.
> They mostly (or exclusively) contain a copy of the homonymous Perl
> script, plus the following:
>
> C:\Opt\Perl512.32\bin :: diff pwhich pwhich.bat
> 0a1,12
> > @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 ';
> 1a14
> > #line 15
> 141a155,157
> >
> > __END__
> > :endofperl
>
> (Useful script, by the way - try "pwhich -a perl" to see all perls.)
>
> My question is:
>
> Do the BAT scripts contain a copy of the Perl script to be backward-
> compatible with some old version of cmd.exe ? Because at least with a
> current cmd.exe you could simply do the following to call Perl with a
> script of the same name as the BAT file (like foo.bat -> foo.pl):
>
>   @CALL %~dp0perl.exe %~dpn0.pl
>
> Or just:
>
>   @CALL perl.exe %~dpn0.pl
>
> Which would use (I think) a perl.exe installed in the same directory as
> the BAT script.
>
> See "CALL /?" in cmd.exe . I'm using this feature a lot since I've
> discovered it.

The idea is that the file is both a valid batch script and a valid perl script. 
Many are probably the result of running pl2bat.bat on a Perl script. The 
documentation in that file (See 'perldoc pl2bat') may answer your questions.

Also, I am not a win32 expert, but isn't the call command intended for 
executing one batch file from another, rather than executing a program?

HTH


--
Brian Raven



Please consider the environment before printing this e-mail.

This e-mail may contain confidential and/or privileged information. If you are 
not the intended recipient or have received this e-mail in error, please advise 
the sender immediately by reply e-mail and delete this message and any 
attachments without retaining a copy.

Any unauthorised copying, disclosure or distribution of the material in this 
e-mail is strictly forbidden.
_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to