Subject: | [PATCH] reëxport subroutines |
If I want to to any further command line option processing in my program
than just what P::U::C provides (--help, --man, --version), then I need
to load G::L again on my own and import GetOptions, thus:
use Pod::Usage::CommandLine;
use Getopt::Long qw(GetOptions);
use Pod::Usage qw(pod2usage);
my %opt;
GetOptions(\%opt, 'foo-switch', 'bar-switch') or pod2usage;
pod2usage unless 1 == keys %opt;
It would be less lame if P::U::C gave me access to those subroutines, as
it has already loaded their modules anyway. Thus:
use Pod::Usage::CommandLine qw(GetOptions pod2usage);
my %opt;
...
The attached patch fixes that.
Subject: | reëxport-subroutines.patch |
diff -ru Pod-Usage-CommandLine-0.03-old/lib/Pod/Usage/CommandLine.pm Pod-Usage-CommandLine-0.03-new/lib/Pod/Usage/CommandLine.pm
--- Pod-Usage-CommandLine-0.03-old/lib/Pod/Usage/CommandLine.pm 2009-03-16 14:08:26.000000000 +0100
+++ Pod-Usage-CommandLine-0.03-new/lib/Pod/Usage/CommandLine.pm 2009-05-05 16:48:49.000000000 +0200
@@ -8,6 +8,8 @@
use Pod::Usage;
use Getopt::Long;
use File::Basename;
+use base 'Exporter';
+our @EXPORT_OK = qw(GetOptions pod2usage);
INIT
{
@@ -36,10 +38,14 @@
=head1 SYNOPSIS
- use Pod::Usage::CommandLine;
+ use Pod::Usage::CommandLine qw(GetOptions pod2usage);
BEGIN { our $VERSION = '1.0'; } # NOTE: Set main version in BEGIN block
+ my %opt;
+ GetOptions(\%opt, @getopt_long_specs) or pod2usage;
+
+
# then, use command line options:
my_program.pl --version
@@ -60,10 +66,13 @@
Set $VERSION in a BEGIN block as shown above so it will get picked up
by the '--version' option.
+=head1 EXPORTS
+
+C<GetOptions> and C<pod2usage> are exported on demand.
+
=head1 SEE ALSO
- L<Pod::Usage>
- L<Getopt::Long>
+L<Pod::Usage>, L<Getopt::Long>
=head1 AUTHOR