I can't help directly but if, as the docs say, you're looking for a data structure similar to that used by HTML::Template this may help get you started.
#!/usr/bin/perl
use strict;
use warnings;
use HTML::Template;
use Data::Dumper;
$Data::Dumper::Indent = 1;
my %h = get_hash();
my @outer;
for my $rep (keys %h){
my @inner;
for my $detail (@{$h{$rep}}){
push @inner, $detail;
}
push @outer, {
rep => $rep,
inner => [@inner],
}
}
my $param = {outer => [@outer]};
print Dumper $param;
exit;
# the following not directly relevant
my $t = HTML::Template->new(filename => 'kwaping.html')
or die "can't parse template: $!";
$t->param($param);
print $t->output;
sub get_hash{
return (
'One' => [
{
'apptype' => 'xxx',
'count' => '123',
'companyid' => 'xxx',
'state' => 'xx'
},
{
'apptype' => 'xxx',
'count' => '123',
'companyid' => 'xxx',
'state' => 'xx'
},
{
'apptype' => 'xxx',
'count' => '123',
'companyid' => 'xxx',
'state' => 'xx'
}
],
'Two' => [
{
'apptype' => 'xxx',
'count' => '123',
'companyid' => 'xxx',
'state' => 'xx'
},
]
);
}
Data::Dumper output:
---------- Capture Output ----------
> "C:\Perl\bin\perl.exe" _new.pl
$VAR1 = {
'outer' => [
{
'inner' => [
{
'apptype' => 'xxx',
'count' => '123',
'companyid' => 'xxx',
'state' => 'xx'
}
],
'rep' => 'Two'
},
{
'inner' => [
{
'apptype' => 'xxx',
'count' => '123',
'companyid' => 'xxx',
'state' => 'xx'
},
{
'apptype' => 'xxx',
'count' => '123',
'companyid' => 'xxx',
'state' => 'xx'
},
{
'apptype' => 'xxx',
'count' => '123',
'companyid' => 'xxx',
'state' => 'xx'
}
],
'rep' => 'One'
}
]
};
> Terminated with exit code 0.