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

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]