Can't get pod2usage verbose to work

M

Martin Gill

Hi

I'm trying to learn perl, so i've been playing with some of the examples
in the documentation.

I tried creating a simple script with Getopt::Long and Pod::Usage.

When I use pod2usage(-verbose => x) where x is less than two, i don't
get to see my SYNOPSIS block, in fact, i get to see nothing at all.

I thought it was my script, so I copy/pasted the example script into a
new file and ran that. Same result.

A quick search in google revealed some old messages in this group that
talked about line endings being a problem. I use SciTE as my editor, so
it was nice and easy to change the line endings of my file. I tried
CR/LF, LF on its own, and CR on it's own as line endings, but still no luck.

Anyone have any ideas what I am doing wrong?

I've attached the sample code I'm working from to the email.

I'm running:
This is perl, v5.8.4 built for MSWin32-x86-multi-thread
Binary build 810 provided by ActiveState Corp.
Built Jun 1 2004 11:52:21

On Windows XP Pro SP2.

Thanks for any help,

Martin

---------------Code-----------------------
use Getopt::Long;
use Pod::Usage;

my $man = 0;
my $help = 0;
## Parse options and print usage if there is a syntax error,
## or if usage was explicitly requested.
GetOptions('help|?' => \$help, man => \$man) or pod2usage(2);
pod2usage(1) if $help;
pod2usage(-verbose => 2) if $man;

## If no arguments were given, then allow STDIN to be used only
## if it's not connected to a terminal (otherwise print usage)
pod2usage("$0: No files given.") if ((@ARGV == 0) && (-t STDIN));
__END__

=head1 NAME

sample - Using GetOpt::Long and Pod::Usage

=head1 SYNOPSIS

sample [options] [file ...]

Options:
-help brief help message
-man full documentation

=head1 OPTIONS

=over 8

=item B<-help>

Print a brief help message and exits.

=item B<-man>

Prints the manual page and exits.

=back

=head1 DESCRIPTION

B<This program> will read the given input file(s) and do something
useful with the contents thereof.

=cut
 
A

A. Sinan Unur

Hi

I'm trying to learn perl, so i've been playing with some of the
examples in the documentation.

I tried creating a simple script with Getopt::Long and Pod::Usage.

When I use pod2usage(-verbose => x) where x is less than two, i don't
get to see my SYNOPSIS block, in fact, i get to see nothing at all.

I thought it was my script, so I copy/pasted the example script into a
new file and ran that. Same result.

It is your script. See below.
---------------Code-----------------------
use Getopt::Long;
use Pod::Usage;

my $man = 0;
my $help = 0;
## Parse options and print usage if there is a syntax error,
## or if usage was explicitly requested.
GetOptions('help|?' => \$help, man => \$man) or pod2usage(2);
pod2usage(1) if $help;
pod2usage(-verbose => 2) if $man;

## If no arguments were given, then allow STDIN to be used only
## if it's not connected to a terminal (otherwise print usage)
pod2usage("$0: No files given.") if ((@ARGV == 0) && (-t
STDIN));
__END__

Why is this __END__ this many spaces over?
=head1 NAME


Reading perldoc perlpod:

A verbatim paragraph is distinguished by having
its first character be a space or a tab.

and:

All command paragraphs (which are typically only
one line long) start with "=", followed by an
identifier,

indicate that the pod directives should be flush against the left margin

Here is what happens when I run your script after I make those changes:

C:\My Documents> perl -v

This is perl, v5.8.4 built for MSWin32-x86-multi-thread

C:\My Documents> cat s.pl
use Getopt::Long;
use Pod::Usage;

my $man = 0;
my $help = 0;
## Parse options and print usage if there is a syntax error,
## or if usage was explicitly requested.
GetOptions('help|?' => \$help, man => \$man) or pod2usage;
....
....

C:\My Documents> perl s.pl
s.pl: No files given.
Usage:
sample [options] [file ...]

Options: -help brief help message -man full documentation

C:\My Documents> perl s.pl -man
NAME
sample - Using GetOpt::Long and Pod::Usage

SYNOPSIS
sample [options] [file ...]

Options: -help brief help message -man full documentation

OPTIONS
-help Print a brief help message and exits.

-man Prints the manual page and exits.

DESCRIPTION
This program will read the given input file(s) and do something
useful
with the contents thereof.

Sinan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top