* Viljo Marrandi ([EMAIL PROTECTED]) [011010 08:44]:
> Hello,
>
> I have problem accessing complex perl data structures from TT. Let's say
> i have following data:
>
> %rec = (
> 42 => {
> name => 'category name',
> story => [
> { id => 15, topic => 'story 1' },
> { id => 16, topic => 'story 2' },
> ],
> },
> 44 => {
> name => 'category name 2',
> story => [
> { id => 17, topic => 'story 3' },
> { id => 19, topic => 'story 4' },
> ],
> },
> );
>
> If i try to print out 'name's from TT doing this:
> [% FOREACH foo = rec %]
> [% foo.name %]
> [% END %]
>
> then nothing, no output at all :(. Now if I try to print out [%
> foo.keys.${0} %] then output is 'key' and ${1} is 'value', why's that?
You're passing a hash, not a list. Try:
[% FOREACH fookey = rec.keys %]
[% rec.$fookey.name %]
[% END %]
Chris
--
Chris Winters ([EMAIL PROTECTED])
Building enterprise-capable snack solutions since 1988.