|
|
| Keep It Simple, Stupid | |
| PerlMonks |
Re: printing a table in html using data read from a text fileby bjelli (Pilgrim) |
| on Jun 08, 2001 at 14:04 UTC ( #86871=note: print w/ replies, xml ) | Need Help?? |
|
HTML::Table is a very handy module that gives you a table object which you can manipulate for a while before finally printing it out. The rows and columns in a HTML::Table are counted on a grid, starting at 1,1. Cells that span several columns and/or rows do not disturb the count: +---+---+---+---+---+ |1/1|2/1|3/1|4/1|5/1| +---+---+---+---+---+ |1/2|2/2|3/2|4/2|5/2| + +---+---+---+---+ | |2/3|3/3 |5/3| +---+---+---+---+---+ |1/4|2/4|3/4|4/4 | +---+---+---+ + |1/5|2/5|3/5| | +---+---+---+---+---+ Here's my test-data:
And the program: I first generate an array that holds the first column, in my example that's (csc,csc,csc,new,other,other). From that I compute a seconde array that hold the count of the words in the first column, here this is (3,0,0,1,2,0). (I bet someone here could turn this into a one-liner <kbd>;-)</kbd> Then I generate the plain table (without spanning cells) And finally I walk down the first column and set the spanning:
The output of the program:
Links and typos fixed june 11, thanks to jeffa
In Section
Seekers of Perl Wisdom
|
|
|||||||||||||||||||||||||||||||||||||