pl2bat - wrap perl code into a batch file
pl2bat -h
pl2bat [-w] [-a argstring] [-s stripsuffix] [files]
pl2bat [-w] [-n ntargs] [-o otherargs] [-s stripsuffix] [files]
This utility converts a perl script into a batch file that can be executed on DOS-like operating systems.
Note that by default, the ``.pl'' suffix will be stripped before adding a ``.bat'' suffix to the supplied file names. This can be controlled with the -s option.
The default behavior is to have the batch file compare the OS
environment variable against "Windows_NT"
. If they match, it uses the %*
construct to refer to all the command line arguments that were given to it, so you'll need to make sure that works on your variant of the command shell. It is known to work in the cmd.exe shell under WindowsNT.
4DOS/NT users will want to put a
ParameterChar = *
line in their initialization file, or execute setdos /p*
in the shell startup file.
On Windows95 and other platforms a nine-argument limit is imposed on
command-line arguments given to the generated batch file, since they may
not support %*
in batch files.
These can be overridden using the -n
and -o
options or the deprecated -a
option.
$
is always assumed). Defaults to /.plx?/
.
/^#!.*perl/
is found in the script, then such a line is inserted just after the new
preamble. The exact line depends on $Config{startperl}
[see the Config manpage]. With the -w
option, " -w"
is added after the value of $Config{startperl}
. If a line matching /^#!.*perl/
already exists in the script, then it is not changed and the -w option is ignored.
C:\> pl2bat foo.pl bar.PM [..creates foo.bat, bar.PM.bat..] C:\> pl2bat -s "/\.pl|\.pm/" foo.pl bar.PM [..creates foo.bat, bar.bat..] C:\> pl2bat < somefile > another.bat C:\> pl2bat > another.bat print scalar reverse "rekcah lrep rehtona tsuj\n"; ^Z [..another.bat is now a certified japh application..] C:\> ren *.bat *.pl C:\> pl2bat -u *.pl [..updates the wrapping of some previously wrapped scripts..] C:\> pl2bat -u -s .bat *.bat [..same as previous example except more dangerous..]
$0
will contain the full name, including the ``.bat'' suffix when the
generated batch file runs. If you don't like this, see runperl.bat for an
alternative way to invoke perl scripts.
Default behavior is to invoke Perl with the -S flag, so Perl will search the PATH to find the script. This may have undesirable effects.
perl, perlwin32, runperl.bat
If rather than formatting bugs, you encounter substantive content errors in these documents, such as mistakes in the explanations or code, please use the perlbug utility included with the Perl distribution.