【发布时间】:2014-04-01 16:26:01
【问题描述】:
我有:
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;
#-----------------------------------------------------------------
#---------------- Documentation / Usage / Help ------------------
=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
从在线示例中复制/粘贴了很多内容。但是,当我执行 script.pl --help 时,什么也没有打印出来,并且脚本退出了。
【问题讨论】:
-
如果切换回使用合法的 POD 会怎样?
-
对不起,我显然对 perl 很陌生 - 你所说的合法 POD 是什么意思?
-
您知道您所说的“几乎从在线示例复制/粘贴”的部分吗?嗯,看来你所做的每一个改变都是一个错误。
-
尤其是缩进严重破坏了它。在 POD 中,缩进文本是逐字块,因此缩进的
=item根本不是 POD item。您可以通过在您的文件上运行pod2text来验证这一点。 -
谢谢,我不知道 perl 中的间距是这样的问题