Having applied the methods at Debugging Template Toolkit I see that I'm passing my TT template:

DUMP: $VAR1 = { 'blist' => { 'Central600' => { 'checked' => 'on', 'curr' => 'off', 'desc' => 'Oregon 600-XTR, May 30-31 ' }, 'TriCities200' => { 'checked' => 'no', 'curr' => 'off', 'desc' => 'Tri-Cities 200, April 18 ' }, 'CoveredBridges400' => { 'checked' => 'on', 'curr' => 'yes', 'desc' => 'Covered Bridges 400, May 9' }, }, # end of %blist # other items }

And in my template file this:

Brevets spec'd manually [% blist.CoveredBridges400.desc %] [% blist.CoveredBridges400.curr %] [% blist.CoveredBridges400.checked %] end Brevets spec'd manually

yields the expected:

Brevets spec'd manually Covered Bridges 400, May 9 off on end Brevets spec'd manually

Yet when I try to access the hash values in some sort of FOREACH construct my lack of TT understanding mocks me by not yeilding up the desc, curr and checked values for each of the hashes in blist.

(This is the current of many iterations in trying to figure out what I don't yet know)

[% FOREACH bb IN blist %] 4 bb $bb <br/> 5 bb.key $bb.key <br/> 6 blist.bb blist.$bb <br/> 7 bb.item desc $bb.key.item('desc')<br/> 7 blist.bb.keys blist.$bb.keys<br/> [% FOREACH bkey = blist.$bb.keys.shift %] [% bkey %] => [% # blist.$bb.$bkey %] [% END %] 7a blist.bb.vals blist.$bb.values<br/> [% FOREACH ba = blist.$bb.values.list %] [% ba %] [% END %] [% FOREACH ba IN blist.bb.values %] $ba [% END %] 8 [% blist.$bb.desc %] blist.($bb.key).desc or blist.bb.desc +<br/> 9 [% blist.$bb.curr %] blist.($bb.key).curr or blist.bb.curr +<br/> 10 [% blist.$bb.checked %] [% blist.$bb.key.checked %] <br/> [% END %]
providing:
4 bb HASH(0xd977f0) 5 bb.key CoveredBridges400 6 blist.bb blist.HASH(0xd977f0) 7 bb.item desc CoveredBridges400('desc') 7 blist.bb.keys blist.ARRAY(0xd8f730) 7a blist.bb.vals blist.ARRAY(0xd8f7b0) 8 blist.(CoveredBridges400).desc or blist.bb.desc 9 blist.(CoveredBridges400).curr or blist.bb.curr 10

In any case I'm not grokking how to walk trough the hash of hashes and extract the values.

So Monks, please take up your favorite cluesticks and beat the rocks that cover my understanding.

Be Appropriate && Follow Your Curiosity

In reply to Hash of Hash Access in Template Toolkit by mikeraz

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.