On Mon, 10 Feb 2003, Dennis Daupert wrote:
>
> I have a db with info about files: filename, author, etc.
>
> I read the info, pump it into an array of hashes. (named @filesinfo).
Sounds like you need to have a hash of arrays of hashrefs :)
my $data = {};
while (my $row = $sth->fetchrow_hashref) { # or whatever you do
push @{ $data->{file_info}->{$row->{dir}} }, $row;
}
my $template = Template->new();
$template->process('foobar.tt', $data) || die $template->error();
then in your template:
[% FOREACH dir = file_info.sort -%]
Directory [% dir %] has the following files:
[% FOREACH file = file_info.$dir -%]
file name is [% file.name %]; file author is [% file.author %]
[% END %]
[% END %]
Or something like that :)
HTH,
- nick
~~~~~~~~~~~~~~~~~~~~
Nick Tonkin {|8^)>
_______________________________________________
templates mailing list
[EMAIL PROTECTED]
http://lists.template-toolkit.org/mailman/listinfo/templates