Subject: | Consider printing POD sections |
Consider adding this tool 'podsec' or whatever you'd like to call it to print POD sections, similar to 'podgrep', but printing the entire sub-section of POD. By default it prints SYNOPSIS section so a quick use case:
Show quoted text
> podsec -s SYNOPSYS Google::ProtocolBuffers | tail -n +2 > synopsis.pl; synopsis.pl
Takes the sample code in the Google::ProtocolBuffers SYNOPSYS (note, it is misspelled) section and creates a script and runs the code.
Cheers.
Subject: | podsec.pl |
#!perl
use strict;
use warnings;
use Getopt::Std;
use Pod::Usage;
use Pod::Find qw( pod_where );
my %opt;
getopts( 's:', \%opt );
if ( !@ARGV ) {
pod2usage( -verbose => 0, -message => "$0: one argument required\n" );
}
$opt{s} = $opt{s} || 'SYNOPSIS';
pod2usage(
-verbose => 99,
-exitval => "NOEXIT",
-sections => $opt{s},
-input => pod_where( {-inc => 1}, $ARGV[0] )
);
__END__
=head1 NAME
podsec - Show POD or sections thereof
=head1 SYNOPSIS
podsec [options] Perl::Module
=head1 DESCRIPTION
Show the relevent POD sections of the requested Perl::Module.
=head1 ARGUMENTS
Perl::Module Perl Module to get POD for.
=head1 OPTIONS
-s section The POD section name. CasE SeNsItIVE.
--section DEFAULT: (or not specified) SYNOPSIS.
=head1 LICENSE
This software is released under the same terms as Perl itself.
If you don't know what that means visit L<http://perl.com/>.
=head1 AUTHOR
Copyright (c) 2018 Michael Vincent
L<http://www.VinsWorld.com>
All rights reserved
=cut