in reply to [Solved] Pod::Usage - Can I have multiple Pods in one script?

I've done *something* like that by using Getopt::Long and Pod::Usage. Basically, when '--help' is specified with other key command line switches, the user gets the appropriate POD section. Otherwise, they can use '--man' to get the full monty.

use strict; use warnings; use Getopt::Long qw(:config no_ignore_case); use Pod::Usage; my %opt; my ( $opt_help, $opt_man, $opt_versions ); GetOptions( [...] 'P|password=s' => \$opt{Pass}, [...] 's|snmp=s' => \$opt{snmp}, [...] 'username=s' => \$opt{user}, [...] 'help!' => \$opt_help, 'man!' => \$opt_man, 'versions!' => \$opt_versions ) or pod2usage( -verbose => 0 ); if ( defined $opt_help ) { pod2usage( -verbose => 99, -sections => "OPTIONS/PASSWORD MODE" ) if defined $opt{Pass}; pod2usage( -verbose => 99, -sections => "OPTIONS/SNMP MODE" ) if defined $opt{snmp}; pod2usage( -verbose => 99, -sections => "OPTIONS/TELNET SSH MODE" +) if ( defined $opt{user} or defined $opt{pass} ); } pod2usage( -verbose => 1 ) if defined $opt_help; pod2usage( -verbose => 2 ) if defined $opt_man; [...] __END__ =head1 NAME [...] =head1 SYNOPSIS [...] =head1 DESCRIPTION [...] =head1 OPTIONS [...] =head2 PASSWORD MODE To activate B<Password Mode>, use the -P option. [...] =head2 SNMP MODE To activate B<SNMP Mode>, use the -s option. [...] =head2 TELNET SSH MODE To activate B<Telnet Mode>, use the -p option without -s. [...] =cut

Replies are listed 'Best First'.
Re^2: Pod::Usage - Can I have multiple Pods in one script?
by Skeeve (Parson) on Jan 20, 2016 at 06:15 UTC

    I also tried that, but it unfortunately failed :( Subsections seemed to be unsupported in 1.33

    Update: I must have done something wrong. Subsections are supported.


    s$$([},&%#}/&/]+}%&{})*;#$&&s&&$^X.($'^"%]=\&(|?*{%
    +.+=%;.#_}\&"^"-+%*).}%:##%}={~=~:.")&e&&s""`$''`"e