Take a look at nested data structures, perlref, perlreftut, and of course perldata.

What you wanna do(IMHO) is create a hash of arrays(a plain hash will do).

functions of interest perlfunc:scalar, perlfunc:keys, perlfunc:shift, perlfunc:push, perlfunc:join, and perlfunc:split.

This is more than enough information to get you started (and more).

#!/usr/bin/perl -w #file://videogamer06.pl #html table, appropriate rowspans. use strict; my %crap = (); my @all3; while(<DATA>) { @all3 = split(',',$_); push @{$crap{shift @all3}}, @all3; } foreach my $key (keys %crap) { print '$key-', @{$crap{$key}}, "\n"; } print "\n", '-' x 60, "\n"; foreach my $key (keys %crap) { print $key,"\t|"; my @twod = @{$crap{$key}}; print join("\t|", @twod); } print "\n", '-' x 60, "\n"; foreach my $key (keys %crap) { print $key; my @twod = @{$crap{$key}}; for my $ix (0..$#twod) { print "\t|", $twod[$ix]; } } #|csc|tech|base| #| |comp| | #| |mous|acm | __DATA__ csc, tech, base csc, comp, acm csc, mous, base
UPDATE:
I reviewed my post, and I found a serious mistake. push @{$crap{shift @all3}}, @all3; should have been push @{$crap{shift @all3}}, \@all3;
Since I made this mistake early on, all my subsequent 'examples' are incorrect. I apologize for this hastiness. I will leave the incorrect code there, but here is hybrid correction:
#!/usr/bin/perl -w #file://www.kibo.com.pl use strict; my @all3=(); my %crap=(); while(<DATA>) { @all3 = split(',',$_); push @{$crap{shift @all3}}, \@all3; } foreach my $key (keys %crap) { print $key,"\t|\n"; my @twod = @{$crap{$key}}; foreach my $reference (@twod) { my @twod2 = @{$reference}; print "\t|", join("\t|", @twod2), "\n"; } print "\n",'-' x 79,"\n"; } __DATA__ a,3,4 a,30,04 a,300,004 a,3000,400 b,3,4 b,30,04 b,300,004 c,3000,400

Anyway, here is a working piece of code (for the actual table). It is a little off spec, but it keeps the 'look' and the logic is easier.
Results wil look like:

foo|       |
   |abc|def|
   |fed|era|
#!/usr/bin/perl -w #file://working.snippet.pl use strict; my %crap = (); my @all3; while(<DATA>) { chomp; @all3 = split(',', $_ ); push @{$crap{shift @all3}}, \@all3; } print "\n", '-' x 60, "\n"; print "<TABLE BORDER=66>\n"; foreach my $key (keys %crap) { my @twod = @{$crap{$key}}; my $rowspan = 2+$#twod; my $colspan = 1+$#{$twod[0]}; print "<TR><TD ROWSPAN=", $rowspan, ">\n", $key, "</TD>\n"; print "<TD COLSPAN=", $colspan, ">&nbsp;</TD></TR>\n"; for my $ref (@twod) { my @hef = @{$ref}; print "<TR>\n"; for my $hef (@hef) { print "<TD>\n $hef \n</TD>\n"; } print "</TR>\n"; } } print "</TABLE>\n"; __DATA__ csc, tech, base csc, comp, acm csc, mous, base dcsc, mo0us, bas0e ecsc, mous, base csc, mou0s, baase bcsc, mo500us, 0bas0e bcsc, m4o0us, b0as0e bcsc, mo1us, ba0se bcsc, m2o0us, b0as0e
UPDATE:
You know, sometimes, late at night, I go beyond idiot.
Please use jeroenes suggestion, as it is brilliant!

 
___crazyinsomniac_______________________________________
Disclaimer: Don't blame. It came from inside the void

perl -e "$q=$_;map({chr unpack qq;H*;,$_}split(q;;,q*H*));print;$q/$q;"


In reply to (crazyinsomniac) Re: printing a table in html using data read from a text file by crazyinsomniac
in thread printing a table in html using data read from a text file by videogamer06

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.