#!/usr/bin/perl -w use Getopt::Std; Getopt::Std::getopts('a:b:c:de', \%options); print "-a:$options{a} "; print "-b:$options{b} "; print "-c:$options{c} "; print "-d:$options{d} "; print "-e:$options{e} ";
#!/usr/bin/perl use Getopt::Long; Getopt::Long::GetOptions( 'page=i' => $page, 'onoff!' => $onoff, 'help' => $wants_help, 'name=s' => $name, 'number:i' => $number); if(defined($page)){ print "page flag set to $page "; } if(defined($onoff)){ print "onoff flag set to $onoff "; } if(defined($wants_help)){ print "help flag set to $wants_help "; } if(defined($name)){ print "name flag set to $name "; } if(defined($number)){ print "number flag set to $number "; }