根据documentation of Pod::Usage , 与 pod2usage(-verbose => 2)
“打印了整个联机帮助页”。但是,在某些情况下,会显示脚本的 perl 源代码而不是格式正确的联机帮助页。
下面是一个例子:
use Pod::Usage qw(pod2usage);
pod2usage(-verbose => 2);
__END__
=head1 NAME
Minimal example
=head1 SYNOPSIS
This is the synopsys section.
=cut
运行脚本:
$ perl test.perl
You need to install the perl-doc package to use this program.
use Pod::Usage qw(pod2usage);
pod2usage(-verbose => 2);
__END__
=head1 NAME
Minimal example
=head1 SYNOPSIS
This is the synopsys section.
=cut
最佳答案
问题是pod2usage
使用命令行程序 perldoc
.如果未安装此程序,则不会进行格式化,您将在输出中获得完整的源代码。
请注意,在问题中,文本“You need to install the perl-doc package to use this program.
”出现在输出中,以提示您正在发生的事情(但是当帮助文本很长并通过管道传送到寻呼机时,该行并不总是可见)。
解决方案:安装 perldoc(例如 apt install perl-doc
在 Ubuntu 上)。在这之后:
$ perl test.perl
NAME
Minimal example
SYNOPSIS
This is the synopsys section.
关于perl 的 pod2usage(-verbose => 2) 显示源代码而不是格式化文档,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49899633/