Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • Using loop.count instead of loop.index makes that code a little simpler (loop.count is always loop.index + 1).

    [% FOREACH object = domain.raObject %] <tr [% IF not (loop.count % 3) %]bgcolor="#EEEEEE"[% END %]>

    Also, I'd tend to do something like this with classes and stylesheets as it makes it easier to change in the future.

    [% FOREACH object = domain.raObject %] <tr class="row_style_[% loop.count % 3 %]">

    You can then define three (or less) styles called "row_style_0", "row_style_1

    • I prefer to do that sort of fiddling in JavaScript, all though it's all much of a muchness. There's a good article [] on how to do stripey tables. Again, I prefer class names to the technique described, but it's a small change.


      • Javascript? If Javascript is the answer, you asked the wrong question!
        • Randal L. Schwartz
        • Stonehenge
        • I beg to differ. JavaScript shares a lot in common with Perl, not least the fact that it has a very bad reputation due to people writing very bad things with it. :-)

          JavaScript is a pleasant language, fairly small with a regular syntax and quite object oriented. It's got closures and objects and garbage collection and exceptions and all the things that you expect from a modern dynamic language. It's worth a second look if all you've ever done is bitch at badly written sites that use it...