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

But getopt always assumes all the named switches take arguments.
getopt('oDI'); # -o, -D & -I take arg. Sets $opt_* as a side e +ffect. getopt('oDI', \%opts); # -o, -D & -I take arg. Values in %opts
Try running this:
#!perl use Getopt::Std; my %opts = (); getopt('z', \%opts); for (keys %opts) { print '$opts{', $_, '} = "', $opts{$_}, "\"\n"; }
you get some interesting results
C:\myperl\temp>perl temp.pl -z $opts{z} = "" C:\myperl\temp>perl temp.pl -y $opts{y} = "1" C:\myperl\temp>perl temp.pl -y -z $opts{y} = "1" $opts{z} = "" C:\myperl\temp>perl temp.pl -z -y $opts{z} = "-y" C:\myperl\temp>temp -z -z $opts{z} = "-z"

--

flounder

Replies are listed 'Best First'.
Re: Re:^3 Passing switches through pl2bat scripts
by demerphq (Chancellor) on Nov 17, 2003 at 18:02 UTC

    Something is wrong. Either the documentation, or the code. The documentation clearly states that the value of a valueless option is to be set to be 1. It does not actually happen. Thus there is an error involved here. Generally the rule is that the code should fit the docs, so I assume the code is buggy. Anyway, ive sent a patch to p5p.


    ---
    demerphq

      First they ignore you, then they laugh at you, then they fight you, then you win.
      -- Gandhi