* Brandon Hall <brandonh.hall at gmail.com> [2004/10/19 12:03]: > I've been attempting to create a data structure to store a list of > emails and display them in the template. I think my problem is in the > data structure, but I haven't been able to get it right. If someone > could correct my code, I think I can figure the rest out. > > Here is how things look. The problem must be in my 'push' line below > or in how i pass it to TT2.
I see a couple of things. First:
> my $file = 'show_company.tpl';
> my $vars = {
> message => "Hello World\n",
> emaillist => @emails
> };
You'll need to do:
my $vars = {
message => "Hello World\n",
emaillist => [EMAIL PROTECTED]
};
For the below to work:
> [% FOREACH email IN emaillist %]
> <tr >
> <td >[% email.from %]</td>
> <td >[% email.to %]</td>
> <td >[% email.subj %]</td>
> <td >[% email.date %]</td>
> </tr>
> [% END %]
You'll need to change the push to be:
push @emails, {
from => "fred",
to => "wilma",
subj => $subj,
date => "today"
};
I.e., push a hashref instead of an arrayref of a hashref. That should
get you going...
(darren)
--
Blessed are the pessimists, for they test their backups.
pgpNGPmICLSoS.pgp
Description: PGP signature
