Hello Monks

I have an output problem within Template. The hash below is being passed to the template file I am simply trying to format it before displaying it. The problem is it seems to being displaying very oddly and I can't figure out why.

# Hash being passed from pl file as %results $VAR1 = { 'Local Studies' => [ { 'closed' => '53' }, { 'open' => '13' } ], 'Local History' => [ { 'open' => '1' }, { 'closed' => '4' } ], 'Reference Dept' => [ { 'open' => '1' }, { 'closed' => '2' } ], 'Admin' => [ { 'open' => '1' } ] };

The template code is below (the idea is a simple table output):

[% USE Dumper %] [% Dumper.dump(results) %] <table border="1"> [% FOREACH key IN results.keys.sort %] <tr> <td>[% key %]</td> <td>[% results.$key.0.open %]</td> <td>[% results.$key.1.closed %]</td> </tr> [% END %] </table>

However the actual output page looks like this:

<tr> <td>Admin</td> <td>1</td> <td></td> </tr> <tr> <td>Local History</td> <td>1</td> <td>4</td> </tr> <tr> <td>Local Studies</td> <td></td> <td></td> </tr> <tr> <td>Reference Dept</td> <td>1</td> <td>2</td> </tr>

Can anyone see why the template is missing the value for the "Local Studies" section? I've been looking at this for a while so I hope it is something silly I am over looking!


In reply to Template display? by packetstormer

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.