($scoretable) = $source =~ m#(.*?)#s; #### my $te = HTML::TableExtract->new; $te->parse($scoretable); foreach my $ts ($te->table_states) { print "Table (", join(",",$ts->coords), "):\n"; foreach my $row ($ts->rows) { print join(',', @$row),"\n"; } } #### Table (0,0): ,1,2,3,4,OT,T Seattle ,0,0,7,7, ,14 Oakland ,7,17,14,0, ,38 #### my $parsed_table = ($te->table_states)[0]; my ($team1_scores, $team2_scores) = ($parsed_table->rows)[1,2]; #### #!/usr/bin/perl -w # Example of how to parse football scores. # Written by Paul Fenwick , October 2001 # Used as an example on PerlMonks. use strict; use HTML::TableExtract; use Data::Dumper; # Normally we'd use LWP::UserAgent to fetch the source, # here we just load it from STDIN/ARGV. local $/ = undef; my $source = <>; # Extract our relevant table. my ($scoretable) = $source =~ m#(.*?)#s; # Parse the table. my $te = HTML::TableExtract->new; $te->parse($scoretable); # Show the structure of what we've parsed. foreach my $ts ($te->table_states) { print "Table (", join(",",$ts->coords), "):\n"; foreach my $row ($ts->rows) { print join(',', @$row),"\n"; } } # Extract the interesting bits we want. my $parsed_table = ($te->table_states)[0]; my ($team1_scores, $team2_scores) = ($parsed_table->rows)[1,2]; # Use Data::Dumper to show that we've succeeded. print Dumper($team1_scores,$team2_scores); __END__