Hi Steve,
> Understanding references is imho one of the most important aspects of
> being able to use Perl effectively, and minimize headache.
>

(stuffing my head into the Llama book)

> That's because iirc TT accepts a hashref as the data, and you must stuff
> your arrayrefs within it.
>
> Here is an example I've cobbled together quickly (using an email template):

snip

> I believe what you want to do is fetch the data from the db as a hashref
> instead, and push the rows into an array to generate your loop topology.
> untested... I haven't used DBI in quite a long time:
>
> my @loop_array;
>
> push @loop_array, $sth->fetchrow_hashref();
>
> my %top_level_tmpl_data;
>
> $top_level_tmpl_data{ db_data } = \...@loop_array;
>
> Then, you can either create an explicit reference to the top level hash
> like this:
>
> my $tmpl_data_ref = \%top_level_tmpl_data;
>
> ...or just skip that step and create the ref as you pass the data into TT.
>
> I hope this is what you were after. Note that I prefer to use references
> directly as opposed to creating array and hash first, but I thought that
> it would be better in this case if I explicitly did things the long way.
>

Hmm, this code look very much like what I want to do with it. I'll
definitely spend some time on it.

Thanks for the code examples & suggestion, this definitely shed some
light onto my question. Thanks!

Regards,
Edward.

-- 
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/


Reply via email to