use HTML::TokeParser;
$p = HTML::TokeParser->new("$tablesource") ||
die "Can't open $tablesource: $!";
# ....
while (my $token = $p->get_token) {
if (($$token[0] eq "S") && (lc $$token[1] eq "td") {
$intd=1;
} elsif ((($$token[0] eq "E") && (lc $$token[1] eq "td") {
$intd=0;
} elsif (($$token[0] eq "S") && (lc $$token[1] eq "font") {
$color=$$token[3]->{color};
} elsif (($$token[0] eq "E") && (lc $$token[1] eq "font")
$color=$defaultcolor;
} elsif ($$token[0] eq "T") {
next unless $intd;
$text=$$token[1];
$color{$text}=$color;
}
}