I thought I'ld let it as an exercise, but...
If I use bgcolor as integer, not boolean, I can easily do that:
<td class="color[:bgcolor:]">....</td>
So I can not only define classes color1,color2 etc, but if in the future we decide we want a 57th special case we haven't thought of before, we don't need to change any code, we just create a class57 and "feed" the bgcolor with the number 57.
As I said before, there is always a matter of good analysis in order to trully and forever seperate perl code (business logic) from presentation (I consider the loops and if/then/else cases in the final HTML pages to be presentation-specific and not business specific)