I think it would make your life easier if you would massage your date into a more appropriate form on the Perl side, instead of fighting with slices of linear arrays within the template.
Here's a simplified example showing a possible data structure:
#!/usr/bin/perl -w use strict; use Template; my $templ = q{ <table> <tr> <td>date</td> [% FOREACH realname IN Users %] <td>[% realname %]</td> [% END %] </tr> [% FOREACH row IN Dates %] <tr> <td>[% row.Day %]</td> [% FOREACH date IN row.EndDates %] <td>[% date %]</td> [% END %] </tr> [% END %] </table> }; my $vars = { Users => [qw(user1 user2 user3 user4 user5)], Dates => [ { Day => 'day1', EndDates => [qw(dl1 dl2 dl3 dl4 dl5)], }, { Day => 'day2', EndDates => [qw(dl6 dl7 dl8 dl9 dl10)], }, { Day => 'day3', EndDates => [qw(dl11 dl12 dl13 dl14 dl15)], }, ], }; my $tt = Template->new(); $tt->process(\$templ, $vars) or die $tt->error();
Output:
| date | user1 | user2 | user3 | user4 | user5 |
| day1 | dl1 | dl2 | dl3 | dl4 | dl5 |
| day2 | dl6 | dl7 | dl8 | dl9 | dl10 |
| day3 | dl11 | dl12 | dl13 | dl14 | dl15 |
In reply to Re^4: How to skip certain values in a foreach loop
by Anonyrnous Monk
in thread How to skip certain values in a foreach loop
by Frederic_S
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |