On Dec 18, 2003, at 8:54 PM, Ricardo SIGNES wrote:

* Mike Blezien <[EMAIL PROTECTED]> [2003-12-18T18:48:23]
been trying to come up with a way, while going through a loop to
alternate a table cell color <td></td>....

I always do something more like:


my $i;
while (<>) {
        print "<tr class='r", ($i++%2), "'> ... </tr>\n"
}

The benefit here is that someday I can replace the 2 with 3 and have
three behaviors.  Yes, that's a minor benefit.

The minus is of course readability. ;) You could accomplish something similar with the ternary operator, to do it as Mike was, without stylesheets.


Ironically, this was my first thought, but I changed my mind while I was typing it. I don't think an extra line or two is a bad price to pay for understanding what's going on. Of course, I'm pretty dumb and need all the visual clues I can get.

James


-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to