I kind of did. The Synopsis in that documentation was where I got that code from:
# Shorthand...top level rows() method assumes the first table found in
# the document if no arguments are supplied.
foreach $row ($te->rows) {
print join(',', @$row), "\n";
I am probably misinterpretting what it says, but I took that to mean that I don't have to examine all matching tables with an (outer) foreach loop if I am only concerned with the 1st table found.
Anyway I took your advice and added the outer foreach loop, but I my data file remains empty. Here is the ammended code:
use HTML::TableExtract;
my $te = HTML::TableExtract->new( headers => [qr/Month\s*/,
qr/First\s*/,
qr/High\s*/,
qr/Low\s*/,
qr/Sett\s*/,
qr/Chg\s*/,
qr/Vol\s*/,
qr/GOWAVE\*\s*/] );
$te->parse_file($sourcefile);
my $record;
open (DATFILE, ">> meg.dat") or die "Unable to open meg.dat: $!";
print DATFILE "Table:\n";
foreach my $ts ($te->table_states) {
foreach my $row ($ts->rows) {
$record = join(',', @$row);
print $record . "\n";
print DATFILE $record . "\n";
}
}
close DATFILE;
And this is the html:
<tr align="center" valign="top">
<td><strong>Month </strong></td>
<td><strong>First </strong></td>
<td><strong>High </strong></td>
<td><strong>Low </strong></td>
<td bgcolor="#f3f3f3"><strong>Sett </strong></td>
<td bgcolor="#f3f3f3"><strong>Chg </strong></td>
<td><strong>Vol</strong></td>
<td><strong>GOWAVE*</strong></td>
<td width="1" style="border-bottom-style:none;"></td>
<td><strong>Vol</strong></td>
<td style="border-right:1px solid #C0C0C0;"><strong>Open Int</strong>
+</td>
</tr>