사용 HTML::Template
그.
#!/usr/bin/perl
use strict;
use warnings;
use HTML::Template;
my $template_text = <<EO_TMPL;
<TMPL_LOOP FILES>
<file>
<state><TMPL_VAR STATE></state>
<timestamp><TMPL_VAR TIME></timestamp>
<location><TMPL_VAR LOCATION></location>
</file>
</TMPL_LOOP>
EO_TMPL
my $tmpl = HTML::Template->new(scalarref => \$template_text);
$tmpl->param(
FILES => [
{ state => 'one', time => 'two', location => 'three' },
{ state => 'alpha', time => 'beta', location => 'gamma' },
]);
print $tmpl->output;
출력 :
<file>
<state>one</state>
<timestamp>two</timestamp>
<location>three</location>
</file>
<file>
<state>alpha</state>
<timestamp>beta</timestamp>
<location>gamma</location>
</file>
대답은 정확히 내가 필요로하는 것입니다. –
안녕하세요! 좋은 ol 'html :: template! – innaM