On 10 Mar 2004 at 20:38, Alan Stewart wrote:

> if you don't mind having your all your usage pod after a __DATA__ statement, 

Here is a variation. The pod is inside the program, but there must be a __DATA__ 
statement and it must have something (anything) after it, so the DATA handle opens, 
even if you don't use what's after (note the period at the end). The seek brings the 
handle back to the beginning of the source file. I don't know if this is entirely 
portable.

###########################

#!perl -w
use strict;

use warnings;
use Getopt::Long;
use Pod::Usage;

my  $help;
if (!GetOptions("help" => \$help)) {
    seek DATA,0,0;
    pod2usage(-exitval => 2, -input => \*DATA)
}
if ($help) {
    seek DATA,0,0;
    pod2usage(-exitval => 1, -input => \*DATA)
}

die "Made it past the options...\n";

=head1 NAME

test - Test Pod::Usage with PAR

=head1 SYNOPSIS

test [options]

=head1 OPTIONS

=over 8

=item B<--help>

Print a brief help message and exit.

=back
=cut
__DATA__
.

###########################

Alan Stewart

Reply via email to