Frederic_S has asked for the wisdom of the Perl Monks concerning the following question:
As you can see, there is some template-toolkit script inbetween. What I would like to achieve, is to break the third foreach loop after the first 5 iterations, then start again AFTER the first five for the next five iterations, then break again and start AFTER the first 10 iterations. Is that possible in Perl? I have no idea how else I could achieve the output I need. The problem is this - the values are read from a database table. This table lists users and their anticipated deadlines for a project. These deadlines are saved once a day for each user, in order to see over time, how a user rates himself. Say I have 5 users for a project. Every day, I save these 5 users to the database, together with todays date and 5 different deadlines. I only need todays date ONCE, but all 5 deadlines. That's the output I'm trying to get in the above code sample. I extract the values of the users into a hash and output these in the first foreach loop. Then I select the saved days and output them in the second foreach loop, creating a new row for each day. Then, I want to output the deadlines as columns in each row. I hope I was able to describe what I'm aiming to achieve - sorry for not being clearer, english isn't my mothertongue :-( Cheers Fred[% IF user.login == Coordinator1 || user.login == Coordinator2 %] <br> <Table class=table> <tr class="[% loop.parity %]"> <td class=title_td colspan=6>Coordinator overview:</td> </tr> <tr> <td class=title_td>Date</td> [% FOREACH AdminData IN AdminValues %] <td class=title_td>[% AdminData.RealName %]</td> [% i = loop.count %] [% n = i %] [% END %] </tr> [% FOREACH Time IN AdminTime %] <tr class="[% loop.parity %]"> <td class=title_td>[% Time.Day %]</td> [% FOREACH AdminDate IN AdminEndDate %] <td class=var_td>[% AdminDate.AppEnd %]</td> [% LAST IF loop.count == i %] [% i = i + n%] [% END %] </tr> [% END %] </Table> [% END %]
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How to skip certain values in a foreach loop
by samarzone (Pilgrim) on Dec 28, 2010 at 12:21 UTC | |
by Frederic_S (Novice) on Dec 28, 2010 at 12:48 UTC | |
by Frederic_S (Novice) on Dec 28, 2010 at 13:09 UTC | |
by Anonyrnous Monk (Hermit) on Dec 28, 2010 at 14:32 UTC | |
by Anonymous Monk on Dec 29, 2010 at 10:38 UTC | |
| |
by samarzone (Pilgrim) on Dec 28, 2010 at 14:31 UTC |