
[英]Preprocess POD with Pod::Weaver before using Pod::Simple::HTML
[英]No output from Pod::Simple
我正在尝试在Perl中使用Pod :: Simple,但没有得到任何输出。 我可以用Pod :: Simple :: Text获得输出。 这是一个简短的测试程序:
use English;
use strict;
use Pod::Simple;
use Pod::Simple::Text;
my $pod_document = <<END_POD;
=pod
=head1 NAME
something
=head1 SYNOPSIS
something else
=cut
END_POD
my $pod_parser = new Pod::Simple();
my $pod_output;
if ($ARGV[0] == 1) {$pod_parser->output_fh(*STDOUT);}
if ($ARGV[0] == 2) {$pod_parser->output_fh(\*STDOUT);}
if ($ARGV[0] == 3) {$pod_parser->output_fh(*STDOUT{IO});}
if ($ARGV[0] == 4) {$pod_parser->output_string(\$pod_output);}
if ($ARGV[0] == 5) {Pod::Simple::Text->filter(\$pod_document);}
$pod_parser->parse_string_document(\$pod_document);
if ($ARGV[0] == 4) {print $pod_output;}
exit 0;
我将此perl代码放入名为pod-test.pl的文件中。 如果我使用命令行参数1、2、3或4运行它,则不会得到任何输出。 “ perl pod-test.pl 5”工作正常。
我应该如何调用output_fh或output_string方法?
Pod::Simple
模块旨在用作您自己编写的Pod格式化程序子类的基类 。 子类提供了生成最终文档的方法,因此,如您所见,如果没有它, Pod::Simple
根本不会产生任何输出。
如果只需要简单文本输出,那么已经在Pod::Simple::Text
为您编写了一个子类。 你会这样使用
use strict;
use warnings;
use English;
use strict;
use Pod::Simple::Text;
my $pod_document = <<END_POD;
=pod
=head1 NAME
something
=head1 SYNOPSIS
something else
=cut
END_POD
my $pod_parser = Pod::Simple::Text->new;
$pod_parser->output_fh(*STDOUT);
$pod_parser->parse_string_document($pod_document);
产量
NAME
something
SYNOPSIS
something else
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.