12 # First we test the getopt function
13 @ARGV = qw(-xo -f foo -y file);
16 print "not " if "@ARGV" ne 'file';
19 print "not " unless $opt_x && $opt_o && opt_y;
22 print "not " unless $opt_f eq 'foo';
26 # Then we try the getopts
27 $opt_o = $opt_i = $opt_f = undef;
28 @ARGV = qw(-foi -i file);
29 getopts('oif:') or print "not ";
32 print "not " unless "@ARGV" eq 'file';
35 print "not " unless $opt_i and $opt_f eq 'oi';
38 print "not " if $opt_o;
41 # Try illegal options, but avoid printing of the error message
43 open(STDERR, ">stderr") || die;
47 !getopts("xf:y") or print "not ";
51 # Then try the Getopt::Long module
55 @ARGV = qw(--help --file foo --foo --nobar --num=5 -- file);
66 print "not " unless $HELP && $FOO && !$BAR && $FILE eq 'foo' && $NO == 5;
69 print "not " unless "@ARGV" eq "file";