use Getopt::Long; $result = GetOptions(...option-descriptions...); ***** &GetOptions("size=i" => \$offset); ***** %optctl = (size => \$offset); &GetOptions(\%optctl, "size=i"); ***** %optctl = (); &GetOptions (\%optctl, "size=i"); ***** $optctl{"size"} = 24; ***** %optctl = (); &GetOptions (\%optctl, "sizes=i@"); ***** -sizes 24 -sizes 48 ***** $optctl{"sizes"} = [24, 48]; ***** &GetOptions ("size=i", "sizes=i@"); ***** -size 10 -sizes 24 -sizes 48 ***** $opt_size = 10; @opt_sizes = (24, 48); ***** foo|bar|blech=s ***** &GetOptions(..."<>", \&mysub...); ***** -foo arg1 -bar arg2 arg3 ***** -foo -bar arg1 arg2 arg3 ***** -foo arg1 -bar arg2 -- arg3 ***** -foo arg1 -bar arg2 arg3 ***** -foo -- arg1 -bar arg2 arg3 ***** use Getopt::Long 2.00; ***** -one -two # $opt_one = '', -two is next option -one -2 # $opt_one = -2 ***** -bar -xxx # $opt_bar = '', '-xxx' is next option -foo -bar # $opt_foo = '-bar' -foo -- # $opt_foo = '--' ***** +foo=blech # $opt_foo = 'blech' --bar= # $opt_bar = '' --bar=-- # $opt_bar = '--' ***** $ret = &GetOptions ('foo=s', \$foo, 'bar=i', 'ar=s', \@ar); ***** $bar = 'blech' $opt_bar = 24 @ar = ('xx', 'yy') ***** @ARGV = qw(-foo 1 bar -foo 2 blech); &GetOptions("foo=i", \$myfoo, "<>", \&mysub); ***** &mysub("bar") \fRwill be called (with $myfoo \fRbeing 1\fR) &mysub("blech") \fRwill be called (with $myfoo \fRbeing 2\fR) ***** @ARGV = qw(-foo 1 bar -foo 2 blech); &GetOptions("foo=i", \$myfoo); ***** $myfoo \fRbecomes 2 @ARGV \fRbecomes qw(bar blech) ***** use strict; use vars qw($opt_rows $opt_cols); use Getopt::Long;