我有一些几乎相同的Perl脚本,所以使用文档几乎类似。例如,prog1.pl
可能是:重构POD文档
use warnings;
use strict;
use Getopt::Long qw(GetOptions);
use Pod::Usage qw(pod2usage);
my $help;
GetOptions(help=>\$help);
pod2usage(-message => "", -verbose => 2, -output => \*STDERR) if $help;
__END__
=head1 SYNOPSIS
prog [OPTIONS]
=head1 OPTIONS
=over 4
=item --help
Print this summary.
=back
=head1 DESCRIPTION
A program
现在prog2.pl
是一个类似的脚本(这里没有显示)。假设它有一组选项的相同文档。对于这个虚拟示例,只需说明两个脚本的help
选项的文档是相同的。我如何重构该文档字符串(即字符串"Print this summary."
),以便我不必在prog1.pl
和prog2.pl
中都重复相同的字符串?
谢谢!我使用了'Pod :: Template'和'IO :: String'。 – 2014-11-02 11:06:42