Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

Greetings, Perl Monks . . . .

Under three different Perls (ActiveState 5.8.3, Cygwin 5.8.2 precompiled, Cygwin 5.8.4 my compile), the following program does two different things, and after playing with it all day, I still can't figure it out.


This program was automatically generated by a 'cookie cutter' program I wrote called It provides the basic skeleton for any quickie command line utility, using Getopt::Std and Pod::Usage to deliver a default --help and --version command for the new file.

The POD documentation embedded at the end normally is much larger; I've edited it here for space.


It runs exactly as expected under AS Perl.

Under either the Cyg prebuilt (or my recent build of 5.8.4 for Cyg), everything works, except --help or -h. Instead of the Pod::Usage you'd expect, you get a blank line.


I have isolated the problem to something in the HELP_MESSAGE() function. Inserting a print "Here I am!!!" in the sub always works. Something seems to be wonky with Pod::Usage.

I thought this might be some sort of problem with $0 (a tip given in the Pod::Usage docs), but no, when I have it print $0, it's ok, even in the varying invocations

$ perl -w $

Also, when I deliberately hose the Pod::Usage module by specifying a bad input file { -input = "/you/are/" }, it properly complains about it.

Just out of paranoia, I tried it with both DOS and UNIX endlines. No difference.


A search of PM returned an article on coupling these two modules in the way I used, but made no mention of bugs or inconsistent behavior.

Any help would be appreciated.

#!/usr/bin/perl -w use warnings; use strict; use Getopt::Std; $Getopt::Std::STANDARD_HELP_VERSION = 1; use Pod::Usage; my $VERSION = v1.0.0; my %options; getopts('h', \%options); HELP_MESSAGE() if $options{'h'}; print "ok"; # main program would go here. sub HELP_MESSAGE { # the program reaches this point, I checked. pod2usage ( { -exit_status => 0, -verbose_level => 1 } ); # pod2usage seems to be doing nothing w/Cyg. # Why? } sub VERSION_MESSAGE { return 1 if (lc $ARGV[0] eq "--help"); print "This program is $0, "; printf "version %vd\n", $VERSION; printf "(Using Perl v%vd)", $^V; exit 0; } __END__ =head1 NAME =head1 SYNOPSIS A one line description, possibly command syntax. [more headers deleted here for conciseness] =head1 OPTIONS =over 4 =item -h, --help Prints synopsis and options, then exits. =item --version Prints version information and exits. =back =head1 ETC [more headers deleted here for conciseness]

In reply to Cygwin Pod::Usage malfunction? by Ambidangerous

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others meditating upon the Monastery: (8)
    As of 2018-06-19 19:01 GMT
    Find Nodes?
      Voting Booth?
      Should cpanminus be part of the standard Perl release?

      Results (114 votes). Check out past polls.