Subject: | documentation does not work with use strict |
Date: | Mon, 15 Jul 2013 10:10:20 +0300 |
To: | bug-Pod-Usage [...] rt.cpan.org |
From: | Michael Gang <michaelgang [...] gmail.com> |
Hi,
The example in the module
use Pod::Usage <https://metacpan.org/module/Pod::Usage>;
use Getopt::Long <https://metacpan.org/module/Getopt::Long>;
## Parse options
GetOptions("help", "man", "flag1") || pod2usage(2);
pod2usage(1) if ($opt_help);
pod2usage(-verbose => 2) if ($opt_man);
## Check for too many filenames
pod2usage("$0: Too many files given.\n") if (@ARGV > 1);
is based on the fact that use strict is not on.
This is generally a bad example as most perl users use strict.
There is a much better example in Getopt::Long
use <http://perldoc.perl.org/functions/use.html> Getopt::Long;
use <http://perldoc.perl.org/functions/use.html> Pod::Usage;
my <http://perldoc.perl.org/functions/my.html> $man = 0;
my <http://perldoc.perl.org/functions/my.html> $help = 0;
GetOptions('help|?' => \$help, man => \$man) or
<http://perldoc.perl.org/functions/or.html> pod2usage(2);
pod2usage(1) if <http://perldoc.perl.org/functions/if.html> $help;
pod2usage(-exitval => 0, -verbose => 2) if
<http://perldoc.perl.org/functions/if.html> $man;
I would just use this example instead.
Thanks,
David