Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

pod::usage "-sections" not working

by johnguillory (Initiate)
on Apr 25, 2013 at 16:52 UTC ( [id://1030698]=perlquestion: print w/replies, xml ) Need Help??

johnguillory has asked for the wisdom of the Perl Monks concerning the following question:

Howdy Cowboys:

I can't get the "-sections" option to work when targeting pod sections. See abstracted code below. Thanks for insight.

use Pod::usage; use Getopt::Long; GetOptions("help"); =head1 SYNOPSIS here's the main usage stuff =head1 SPECIAL special usage stuff here... =cut # This prints SYNOPSIS above just fine as expected: pod2usage(-verbose => 0) if ($opt_help); # This only prints the '-message' and nothing else: pod2usage({-verbose = > 99, -sections => [qw(SPECIAL)], -message => "Here's special stuff...\n"; });

Replies are listed 'Best First'.
Re: pod::usage "-sections" not working
by toolic (Bishop) on Apr 25, 2013 at 17:16 UTC
    After fixing several syntax errors in your code, I get -special to work by adding a blank line after each =head1 line:
    use warnings; use strict; use Pod::Usage; use Getopt::Long; GetOptions("help"); =head1 SYNOPSIS here's the main usage stuff =head1 SPECIAL special usage stuff here... =cut # This prints SYNOPSIS above just fine as expected: #pod2usage(-verbose => 0) if ($opt_help); # This only prints the '-message' and nothing else: pod2usage({-verbose => 99, -sections => [qw(SPECIAL)], -message => "Here's special stuff...\n", }); __END__ Here's special stuff... Special: special usage stuff here...

    You should use podchecker on your code:

    *** WARNING: empty section in previous paragraph at line ... in file . +..

      Weird...I've copied your code and still getting just the message and not the pod section "special". No doubt I must be overlooking something simple. I'll look some more. Thanks toolic. J

        If what you say is based on accurate copy/test of toolic's code, then next you'd best tell us about any and ALL untoward outputs.

        Better yet, you might want to walk thru your/toolic's code with the debugger and tell us what that discloses.


        If you didn't program your executable by toggling in binary, it wasn't really programming!

        It should be something simple. Try this for the SPECIAL section:
        #!/usr/bin/perl BEGIN { $| = 1; $^W = 1; } use strict; use warnings; use Pod::Usage; use Getopt::Long; my $help = 0; pod2usage(2) unless GetOptions('help|?' => \$help); my $verbose = 99; my $message_text = "special usage stuff here...\n"; my $sections = 'SPECIAL'; pod2usage( -verbose => $verbose, -message => $message_text, -sections => $sections, ); __END__ =head1 SYNOPSIS here's the main usage stuff =head1 SPECIAL special usage stuff here... =cut
Re: pod::usage "-sections" not working
by Anonymous Monk on Apr 26, 2013 at 07:06 UTC

    FYI, this is how your failing pod is parsed

    $ perl -MPod::Simple::DumpAsXML -e " Pod::Simple::DumpAsXML->filter(s +hift)->any_errata_seen" udge <Document start_line="5"> <head1 start_line="5"> SYNOPSIS here&#39;s the main usage stuff </head1> <head1 start_line="8"> SPECIAL special usage stuff here... </head1> </Document>

    Corrected pod, like toolic wrote, with the head sections being one word strings :)

    $ perl -MPod::Simple::DumpAsXML -e " Pod::Simple::DumpAsXML->filter(s +hift)->any_errata_seen" udge <Document start_line="5"> <head1 start_line="5"> SYNOPSIS </head1> <VerbatimFormatted start_line="7" xml:space="preserve"> here&#39;s the main usage stuff </VerbatimFormatted> <head1 start_line="9"> SPECIAL </head1> <VerbatimFormatted start_line="11" xml:space="preserve"> special usage stuff here... </VerbatimFormatted> </Document>

    In pod, empty line is paragraph separator, perlpod, perlpodspec

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1030698]
Approved by toolic
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (5)
As of 2024-04-23 16:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found