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.
PURPOSE
This program was automatically generated by a 'cookie cutter' program I wrote called anew.pl. 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.
MISBEHAVIOR
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.
MY TESTS
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 test.pl $ test.pl
Also, when I deliberately hose the Pod::Usage module by specifying a bad input file { -input = "/you/are/hosed.pl" }, it properly complains about it.
Just out of paranoia, I tried it with both DOS and UNIX endlines. No difference.
FINALLY
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.
Server Error (Error ID 1619167a2051870)#!/usr/bin/perl -w test.pl 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 test.pl =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]
An error has occurred. The site administrators have been notified of the problem and will likely soon fix it. We thank you, for you're patients.
Replies are listed 'Best First'. | |
---|---|
Re: Cygwin Pod::Usage malfunction?
by eric256 (Parson) on May 21, 2004 at 05:04 UTC | |
by Ambidangerous (Scribe) on May 21, 2004 at 11:39 UTC | |
Re: Cygwin Pod::Usage malfunction?
by stefan k (Curate) on May 21, 2004 at 14:38 UTC | |
by Ambidangerous (Scribe) on May 21, 2004 at 15:25 UTC |