develooper Front page | perl.perl5.porters | Postings from June 2015

Batch file generation for installed scripts on Windows

Thread Next
From:
A. Sinan Unur
Date:
June 2, 2015 12:17
Subject:
Batch file generation for installed scripts on Windows
Message ID:
CABbccAM6dm8YxN3S3Ae_djy6zzefkC2+FhGRV5XqBCijT48rSA@mail.gmail.com
I am wondering exactly where the batch files for installed scripts are
generated on Windows.

I try to keep a variety of Perl installations, and use one as my main
one. Usually, switching between those end up involving having to
prepend my %PATH% with the appropriate Perl bin locations even if I
invoke the scripts using their full paths. E.g.:

C:\> c:\opt\perl-5.22.0\bin\corelist.bat
'perl' is not recognized as an internal or external command,
operable program or batch file.
You do not have Perl in your PATH.

This is because of the standard preamble:

: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

I do not see if any problems would be caused by actually not relying
on perl being in %PATH% and instead writing the absolute path to perl
in the batch file as in

c:\opt\perl-5.22.0\bin\perl -x -S %0 %*

As far as I can tell, all this requires is to use $^X instead of perl
in win32\bin\pl2bat.bat.

Are there any pitfalls I am not seeing?

-- Sinan

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About