http://paperlined.org/dev/perl/modules/documentation/Getopt::Long.pl

#!/usr/bin/perl

# a starting skeleton for using Getopt::Long

    use strict;
    use warnings;

    use Getopt::Long;

    use Data::Dumper;
    #use Devel::Comments;           # uncomment this during development to enable the ### debugging statements


our %ARGV;
GetOptions( \%ARGV,
                map {"$_:s"}        # all arguments are optional, like Getopt::Casual
    "help|h|?",         # this help text
    "current|c",        # act upon current branch only
    "remote|r",         # compare with remote only; do not compare local-to-local branches
    "max_diff|md",      # max diff (default 100; see below for details)
    "ff",               # don't just check, try to fast forward also
) or usage();
%ARGV = map {length()?$_:1} %ARGV;      # arguments are optional
$ARGV{help} and usage();



die Dumper \%ARGV;







sub usage {
    print "Usage:  test_program.pl <blah> <blah>\n";
    usage_getopt();
    exit;
}



# Poor-man's self-documenting arguments, like Getopt::Lazy or Getopt::Long::Descriptive,
# but works with the stock Getopt::Long.
# The per-argument documentation comes from the source code comments.
#
# It greps the source code, so it's somewhat brittle and relies on a specific format:
#       - the first line starts with "GetOptions("
#       - arguments should be on separate lines
#       - the last line starts with ")"
sub usage_getopt {
    @ARGV = ($0);
    while (<>) {
        next if !(/^\s*GetOptions/ .. /^\s*\)/) || /^\s*(GetOptions|\)|map)/;
        printf "  %-30s", /['"](.*?)['"]/ ? join( ", ", map { s/[=:][sif]$//; /../ ? "--$_" : "-$_" } split /\|/, $1 ) : '';
        /.*#/#/ and print or print "\n";
    }
}


Generated by GNU enscript 1.6.4.