我正在尝试提取 Perl POD 的一部分,仅此而已。如果我运行以下命令:
use strict;
use warnings;
use Pod::Simple;
use Pod::Text;
=head1 podTest
normal pod
=cut
print "normalPod:\n";
my $writeNormalPod = Pod::Text->new();
$writeNormalPod->parse_from_file(__FILE__);
=pod
all pod
=cut
print "\nallPod:\n";
my $writePod = Pod::Text->new();
$writePod->accept_targets( ('special') );
$writePod->parse_from_file(__FILE__);
=begin special
special pod
=end special
=cut
print "\nspecialPod:\n";
my $writeSpecialPod = Pod::Text->new();
# what to have here?
$writeSpecialPod->parse_from_file(__FILE__);
# in order to print "special pod" and nothing else
然后我得到输出:
normalPod:
podTest
normal pod
all pod
allPod:
podTest
normal pod
all pod
special pod
specialPod:
我怎样才能得到special pod
而没有别的?
我尝试过的事情:
- 不接受的代码、指令和目标
- 附加代码(以及 cut、pod 和 whiteline)处理程序
- 网络搜索(充其量,这会显示如何使用格式名称)
有没有一种简单的方法可以只从 POD 中获取特定格式,或者我应该自己解析文件?