For what it is worth, here is some GetOpt_Long code that I recently used:
use strict;
use Getopt::Long;
use Pod::Usage;
my $verbose = 0;
my %opts = ('verbose' => \$verbose);
GetOptions(\%opts, ## throw our options into a hash
"infile=s", ## incoming mbox file
"offset=i", ## seek position (in bytes)
"logfile=s", ## file to log into
"onerun!", ## only read the first message
"maxrun|max=i", ## maximum number of messages to read
"verbose+", ## set verbosity level
"finduser!", ## attempt to perform user lookup.
"nslookup!", ## attempt to perform nslookup for zone ... slo
+w
"help|?", ## prints usage message.
"man", ## prints entire POD.
) or pod2usage(0);
pod2usage(-verbose => 2) if exists $opts{man};
pod2usage(-verbose => 1) if exists $opts{help};
pod2usage(-msg => "missing infile: --help for more information",
-verbose => 0) unless exists $opts{infile};
etc, etc
...and then my POD has a SYNOPSIS and an OPTIONS AND ARGUMENTS section.
I, like
naChoZ, prefer the use of an options hash. It makes it easier when I
need them in a subroutine I can just pass a reference to that hash.
The
Getopt::Long POD suggested the use of
Pod::Usage.
-xtype
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.