in reply to Re: Passing switches through pl2bat scripts
in thread Passing switches through pl2bat scripts

The first -x is a red herring, and perhaps I should have chosen a better example and avoided using -x in my script. However, as the results of join(' ',@ARGV)."\n"; demonstrate, the perl script ends up with a -x that is not processed by getopt(). Here's a better example:
@rem = '--*-Perl-*-- @echo off perl -x -S "%~dpnx0" -z %* goto endofperl @rem '; #!perl use Getopt::Std; print join(' ',@ARGV)."\n"; my %opts = (); getopt('z', \%opts); print "z found\n" if $opts{'z'}; __END__ Results: C:\>x -z C:\>x -z -z -z z found :endofperl

Replies are listed 'Best First'.
Re: Re^2: Passing switches through pl2bat scripts
by ptkdb (Monk) on Nov 17, 2003 at 15:43 UTC
    The issue is basically the same. At some point 'perl' stops accepting arguments/options to the interpreter itself and starts handing them to the script as @ARGV.

    In a typical invocation

    perl @perlOpts filename.pl @scriptOpts

    everything after filename.pl shows up in @ARGV.

    The question becomes, where is that point in your invocation of 'perl' in this particular context?

      In my example, the "%~dpnx0" is the equivalent of filename.pl in your example, so the -z should be passed through. My question has been answered, though, I was misled by the documentation of getopt() and am now using getopts() instead.