Hi, I'm building up a data structure using :

while (@fetch = $sth1->fetchrow) { $vendor = $fetch[0]; $terminal_id = $fetch[1]; $terminal_name = $fetch[3]; $refunds = $fetch[4]; $sales = $fetch[5]; $count = $fetch[6]; $vendor_sales{$vendor}{terminals}{$terminal_id}{terminal_name} + = $terminal_name; $vendor_sales{$vendor}{terminals}{$terminal_id}{sales} = $sale +s; $vendor_sales{$vendor}{terminals}{$terminal_id}{refunds} = $re +funds; $vendor_sales{$vendor}{terminals}{$terminal_id}{count} = $coun +t; }

It gives me the following structure :

'Book Shop' => { '10' => { 'count' => 222, 'refunds' => '90.00', 'sales' => '1200', 'terminal_name' => 'Front Till' }, '20' => { 'count' => 149, 'refunds' => '124.00', 'sales' => '7000.00', 'terminal_name' => 'Side Till' } }, 'Sweet Shop' => { '40' => { 'count' => 2, 'refunds' => '0.00', 'sales' => '400.00', 'terminal_name' => 'Cash Till +' }, '60' => { 'count' => 241, 'refunds' => '20.00', 'sales' => '600.00', 'terminal_name' => 'Credit Til +l' } }

How can I access the different elements in TT :

[% FOREACH vendor IN vendor_sales %] [% vendor.key %] : [% vendor.terminals.terminal_name %] [% END %]

Many Thanks


In reply to Accessing Array of Hashes in TT by swandown

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.