I'm about to go nuts so here I am :)
I'm trying to make documentation for my Perl program, but I never manage to get Getopt::Long and pod2man working.
Here is a simple program I wrote for testing purpose:
#!/usr/bin/perl
use strict;
use warnings;
use Getopt::Long;
use Pod::Usage;
Getopt::Long::Configure ("bundling");
my $option = "";
my $verbose = 1;
my $quiet = 0;
my $man = 0;
my $help = 0;
GetOptions (
"option=s" => \$option,
"verbose" => sub { $verbose = 1; $quiet = 0 },
"quiet|noverbose" => sub { $verbose = 0; $quiet = 1 },
"help|?" => \$help,
man => \$man
) or pod2usage("Error in command line.\n");
pod2usage(1) if $help;
pod2usage(-exitval => 0, -verbose => 2) if $man;
print "my programm here\n";
__END__
=head1 NAME
my-prog.pl - Customized mysqldump utility
=head1 SYNOPSIS
my-prog.pl [OPTIONS]
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.
=item B<--option>
Option description
=item B<--verbose>
Option description
=back
=head1 DESCRIPTION
B<my-prog.pl> is doing something.
=head1 AUTHOR
B<Me>
=cut
Unfortunately, when I do this :
./my-prog.pl --help
Nothing appears. Worse, when I do this :
./my-prog.pl --man
I get kind of a curses page with my whole program in it (every line of my program, not just the help manual).
Before I go crazy and just go back with a custom print_help() subroutine, could you please help me?
Thanks in advance :)
EDIT 1: Program modified thanks to @toolic. Now, my --help works fine but --man is showing me the whole source code of my program in a "man" like page. I run this script with Perl 5.14.2 on Debian Wheezy.