Question 6: A Perl solution
sub extract_data { my($doc) = @_; $cell_data = {}; my $r = 0; foreach my $row ($doc->findnodes(q{//tr[./td]})) { my @vals = map { $_->to_literal; } $row->findnodes(q{./td}); foreach my $c (0..$#vals) { my $ref = $cols[$c] . $rows[$r]; $cell_data->{$ref} = $vals[$c]; } $r++; } die "No data found" unless keys %$cell_data; } # ...