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

when i used the following pod usage in a perl script in linux it works

Pod::Usage::pod2usage(1) if ($help);

But when I use the same in windows it didn't work.
Do anyone has any idea, what causes this issue?
Thanks,
Tom

Replies are listed 'Best First'.
Re: Pod::Usage issue.
by zwon (Abbot) on Sep 17, 2009 at 15:57 UTC

    Check if $0 is properly set. If it isn't, then see CAVEATS section in the Pod::Usage documentation.

Re: Pod::Usage issue.
by Anonymous Monk on Sep 17, 2009 at 15:30 UTC
    AND I get $help like the below

    GetOptions(

    'h|help' => \$help
    );

    Do you know where I am doing it wrong?

    Thanks,
    Tom
Re: Pod::Usage issue.
by Khen1950fx (Canon) on Sep 18, 2009 at 00:23 UTC
    I believe that Pod::Usage::pod2usage refers to pod2usage.PL which is a command line script; however, I think that you meant to use Pod::Usage, a part of the core. I used Pod::Usage for this script:

    #!/sw/bin/perl use strict; use warnings; use Getopt::Long; use Pod::Usage; my $help = 0; GetOptions('help|?' => \$help) or pod2usage(2); pod2usage(1) if ($help); pod2usage(-exitval => 1, -verbose => 2); __END__ 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
      I believe that Pod::Usage::pod2usage refers to pod2usage.PL which is a command line script; however, I think that you meant to use Pod::Usage, a part of the core. I used Pod::Usage for this script

      Why? That is complete nonsense.

Re: Pod::Usage issue.
by Anonymous Monk on Sep 17, 2009 at 16:37 UTC
    pod2usage(-exitstatus => 1, -verbose => 2, -input => 'docu.pod'); pod2usage(-exitstatus => 1, -verbose => 2, -input => $0); pod2usage(-exitstatus => 1, -verbose => 2, -input => __FILE__); pod2usage(-exitstatus => 1, -verbose => 2, -input => \*DATA);