Para crear tu plantilla XML usa HTML::Template:
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;