SYNOPSIS
Shows the use of Getopt::Auto
.
./tour.pl <options>
DESCRIPTION
Some things to try.
The options listed below. Pretty obvious.
tour.pl
without any options. Notice how we check for that. Notice use Getopt::Auto
has a hashref as argument. The okerror
allows some additional processing after command-line errors (such as "not a registered option") are detected.
tour.pl -food
: Notice how it's split up.
tour.pl --notexpected notfound - notwanted
. Notice that --notexpected (double dash) is left on the command line, whereas -notexpected (single dash) would not be. "notfound" is something that might have been processed by --notexpected, had it been expected. "notwanted" would not be processed in any case because it follows the "Cease and Desist" marker, "-".
tour.pl --itemopt 12 --itemopt xy
demonstrates multiple uses of a single option (not very exciting) and how an option can process its values. Complexity limited only by your imagination (and tolerance for user errors!)
tour.pl --item work
, just to prove that the documentation does not lie.
tour.pl --nodef
. What a surprise! Where's the =head2?
OPTIONS
Ok, here we go.
-u, --usage - Prints the DESCRIPTION.
-h, --help - Overrides the builtin.
-c, --cutup - The c option
-f - The f option, part of the -food demo
Cutup (and c) do not have subs, so to see that they are called, we must check %options.
As we're going to all this trouble to create POD, it seems a shame not to use it. Note that help() is not called in the code. It happens before anything else.
work - do the work!
This would be a bare option, except that we've said 'nobare' in the configuration to outlaw bareness. This is not a nude beach, after all.
--item options
Note that there is no ' - ', so not an option What follows is an option that is introduced by "=item".