http://qs321.pair.com?node_id=1119335


in reply to GetOpt Organization

My default - less or more:

use Getopt::Long; use Pod::Usage; # IMHO a must Getopt::Long::Configure("no_ignore_case"); # double your options ;-) GetOptions(\%options, "help", "foo=s","bar=s",); # or what ever pod2usage( -exitstatus => 0, -verbose => 2 ) if $options{help}; foreach my $option (%options ) { pod2usage( -exitstatus => 2, -verbose => 1 ) unless $option; } __END__ # POD section here

Something like this is also very handy (should be self explaining):

GetOptions( \%options, "help", "suffix:s", "amount=i", "dir=s", "logpath=s", " +From=s", "Subject:s", "Data:s", "Host:s", "patterns=s{1,}" => \@patterns, "To=s{1,}" => \@recipients ); # stuff __END__ ./foo.pl -a 2 \ -d /path/to/dir \ -l /path/to/logs \ -F user@domain -s suffix \ -p foo bar \ -T user@domain other@domain

Hint: If you declare "foo", you can call it as -f as well as --foo.

Regards, Karl

«The Crux of the Biscuit is the Apostrophe»