RE: BAT scripts in bin\ directory

Brian Raven <[email protected]> Mon, 27 Feb 2012 11:47:09 +0000
Newsgroups gmane.comp.lang.perl.active-perl
Message-ID <F4203BE2BBEC5F4AB88CE7503B82EAB00585926FD5@pcacoexm01.europe.nyx.com>
> -----Original Message-----
> From: [email protected] [mailto:activeperl-
> [email protected]] On Behalf Of Michael Ludwig
> Sent: 25 February 2012 10:33
> To: [email protected]
> 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
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs