Read the man page to Getopt::Std a little closer.
NAME
getopt - Process single-character switches with switch clustering
getopts - Process single-character switches with switch clustering
SYNOPSIS
use Getopt::Std;
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
getopts('oif:'); # -o & -i are boolean flags, -f takes an argumen
+t
# Sets $opt_* as a side effect.
getopts('oif:', \%opts); # options as above. Values in %opts
You want
getopts not
getopt. Because
getopt is expecting a value and
getopts is for binary flags. when you do a
C:\>z -z
you are setting the value of
%opt{z} == "" which is false.
<code>
C:\>z -z -z
sets the value of
%opt{z} == "-z" which is evaluated as true.
Don't feel bad, I've been there and done that.