http://qs321.pair.com?node_id=1030706


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