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!!
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Alternating colors for HTML Table's
by marto (Cardinal) on Sep 06, 2007 at 11:18 UTC | |
Re: Alternating colors for HTML Table's
by ctilmes (Vicar) on Sep 06, 2007 at 10:45 UTC | |
Re: Alternating colors for HTML Table's
by moritz (Cardinal) on Sep 06, 2007 at 11:29 UTC | |
by narainhere (Monk) on Sep 06, 2007 at 11:54 UTC | |
Re: Alternating colors for HTML Table's
by hawtin (Prior) on Sep 06, 2007 at 14:17 UTC | |
Re: Alternating colors for HTML Table's
by Lorphos (Novice) on Sep 06, 2007 at 14:29 UTC | |
Re: Alternating colors for HTML Table's
by Anonymous Monk on Sep 06, 2007 at 10:57 UTC |
Back to
Seekers of Perl Wisdom