<div dir="ltr"><div>I am not sure if this is what you meant, but using your data I wrote two examples here: <a href="https://perlmaven.com/template-toolkit-hash-of-hash">https://perlmaven.com/template-toolkit-hash-of-hash</a></div><div><br></div><div>Gabor<br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Aug 23, 2020 at 12:33 AM Richard Reina <<a href="mailto:gatorreina@gmail.com">gatorreina@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">I have the following perl multidimensional hash that is passed from<br>
Dancer to Template Toolkit as a hash reference. I am having trouble<br>
figuring out how to display it in Template Toolkit.<br>
<br>
$VAR1 = {<br>
          'TylerMontgomery(2022)' => {<br>
                                   'so' => 1,<br>
                                   'bb' => 1,<br>
                                   'rbis' => 0,<br>
                                   'atbats' => 7,<br>
                                   'runs' => 2,<br>
                                   'hits' => 2<br>
                                 },<br>
          'ChaseLangan(2022)' => {<br>
                                     'runs' => 4,<br>
                                     'hits' => 4,<br>
                                     'atbats' => 5,<br>
                                     'bb' => 0,<br>
                                     'rbis' => 2,<br>
                                     'so' => 1<br>
                                   },<br>
          'BryceJones(2021)' => {<br>
                            'hits' => 2,<br>
                            'runs' => 2,<br>
                            'atbats' => 4,<br>
                            'bb' => 1,<br>
                            'rbis' => 4,<br>
                            'so' => 1<br>
                          },<br>
};<br>
<br>
This is how I iterate it in perl.<br>
<br>
foreach my $name (sort keys %season) {<br>
        printf "%-27.27s", "$name: ";<br>
        foreach my $stat (sort keys %{ $season{$name} }) {<br>
            printf "%-12.12s", "$stat: $season{$name}{$stat} ";<br>
         ## cal. avg<br>
 $season{$name}{AVG} = $season{$name}{hits} / $season{$name}{atbats};<br>
        }<br>
<br>
<br>
    printf "%4s %.3f\n", "avg:", $season{$name}{AVG};<br>
}<br>
<br>
I then pass it back to my dancer app as a ref. with return \%season;<br>
and then to template toolkit with:<br>
<br>
  template '<a href="http://softball.tt" rel="noreferrer" target="_blank">softball.tt</a>' => {<br>
<br>
        'title' => 'Get Softball Season Stats',<br>
        'Season' => $season,<br>
<br>
<br>
    }, {};<br>
<br>
But I am lost trying to get it to display with template toolkit.<br>
Here's what I've tried so far.<br>
<br>
<table style="width:100%; line-height:40px;"><br>
        <% FOREACH Season = Season %><br>
        <tr><br>
          <td width="5">Season.key <% Season.key %></td><br>
          <td width="5">Season.val <% Season.value %></td><br>
          <td width="5">Season.val.atbats <% Season.value.atbats %><br>
          <td width="5">Season.val.hits <% Season.value.hits %><br>
        </tr><br>
        <% END %><br>
<br>
Thanks for any help.<br>
_______________________________________________<br>
dancer-users mailing list<br>
<a href="mailto:dancer-users@lists.preshweb.co.uk" target="_blank">dancer-users@lists.preshweb.co.uk</a><br>
<a href="https://lists.preshweb.co.uk/mailman/listinfo/dancer-users" rel="noreferrer" target="_blank">https://lists.preshweb.co.uk/mailman/listinfo/dancer-users</a><br>
</blockquote></div></div>