Hi there! I have the following construction in my program:
[% 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 %]
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

In reply to How to skip certain values in a foreach loop by Frederic_S

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.