I use this all the time, usually for background colors:# In the configuration section... my @Toggles = ('on', 'off'); # In some loop in the code... $Toggles[$flip = !$flip]
Voila!my @BGColors = ('#dddddd', '#ffffff'); for (1..10){ # As you loop through a database query result or somethin +g print qq{ <tr bgcolor="$BGColors[$flip = !$flip]"> <td>$_</td> </tr> }; }
An easily configured, pretty-to-behold alternating background color.
Notes:
Enjoy!# To cycle through any number of elements... my @Cheers = ('hip', 'hip', 'hoo', 'ray'); my $flip = -1; for (1..12){ print "$Cheers[$flip = ++$flip % 4]\n"; }
Russ
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
RE: Flipper
by mdillon (Priest) on May 20, 2000 at 06:38 UTC | |
by Russ (Deacon) on May 20, 2000 at 06:58 UTC | |
|
RE: Flipper
by gregorovius (Friar) on May 21, 2000 at 05:18 UTC | |
|
RE: Flipper
by merlyn (Sage) on May 21, 2000 at 04:12 UTC | |
by Russ (Deacon) on May 21, 2000 at 12:25 UTC | |
by turnstep (Parson) on May 21, 2000 at 20:41 UTC | |
by Russ (Deacon) on May 22, 2000 at 04:58 UTC |