This does:@rem = '--*-Perl-*-- @echo off perl -x "%~dpnx0" %* goto endofperl @rem '; #!perl use Getopt::Std; my %opts = (); getopt('z', \%opts); print "z\n" if $opts{'z'}; __END__ :endofperl
So, by adding -z to the parameters passed within the script, it prints the 'z' when I run this script with -z. That is to say, it has to be provided by the user and hard-coded in the .cmd script to work.@rem = '--*-Perl-*-- @echo off perl -z "%~dpnx0" -z %* goto endofperl @rem '; #!perl use Getopt::Std; my %opts = (); getopt('z', \%opts); print "z\n" if $opts{'z'}; __END__ :endofperl
If I add the following line:
then I get this (script is called z.cmd):print join(' ',@ARGV)."\n";
So, both the -z that is hard-coded, and the -z that is user-supplied, get through to the script, but getopt() only picks it up if both are there.C:\>z -z C:\>z -z -z -z z
Updated: Changed example to -z to avoid confusion with the -x parameter to perl itself.
In reply to Passing switches through pl2bat scripts by PhilHibbs
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |