Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: pod::usage "-sections" not working

by toolic (Bishop)
on Apr 25, 2013 at 17:16 UTC ( [id://1030706]=note: print w/replies, xml ) Need Help??


in reply to pod::usage "-sections" not working

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 . +..

Replies are listed 'Best First'.
Re^2: pod::usage "-sections" not working
by johnguillory (Initiate) on Apr 25, 2013 at 18:31 UTC

    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

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (2)
As of 2024-04-25 03:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found