in reply to printing a table in html using data read from a text file

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;"