foreach my $project(@projectdb) {
$color = '#ffffff';
$color = '#e1e1e1e' if $cnt%2; #### nifty cmd
print qq¦<tr bgcolor="$color"><td>...¦;
}
...the rest is left as an exercise to the reader. ;-)
Seems a modifier with a modulus and "counting" to store in $cnt is the long way around the bush, but in the spirit of TMTOWTDI . . . .
$lightbg = 'row1';
$darkbg = 'row2';
......
foreach my $project(@projectdb) {
$class = ($class eq $lightbg)?$darkbg:$lightbg;
print qq¦<tr><td class="$class">...</td>....¦;
}
I like it rocknbil. I usually do the above code like this:
I define $altbgcone/two somewhere and then inside of the loop, I do:
($altbgcone,$altbgctwo)=($altbgctwo,$altbgcone);
print qq¦<tr bgcolor="$caltbgcone"><td>...¦;