根据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
Run Code Online (Sandbox Code Playgroud)
运行脚本:
$ 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
Run Code Online (Sandbox Code Playgroud)
问题是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.
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
154 次 |
| 最近记录: |