narainhere has asked for the wisdom of the Perl Monks concerning the following question:
Hi monks,
I would like to share the wisdom I gained.We come across situations when we need to generate a HTML table and stuff some data into it.If the table contains large number of rows we would use bi-(or)multi-color to make it easier to read and for some visual appeal. We can do it in a line of code
This keeps on swapping the colors for each row and code too will look neat and simple.Any more simplification welcomed!!@colors=("blue","green"); foreach $row(@rows) { print "<TR BGCOLOR=".$colors[push(@colors,shift(@colors))- +@colors].">".$row."</TR>"; }
Be inspired by Perl REGEX when you choose your spouse!!
Back to
Seekers of Perl Wisdom