Hi Joe,
You can do that two ways. One, you could check to see if any tables matched:
if ($te->table_states) { ... }
Since you seem to be expecting only a single matched table in the document, however, the table extract object behaves the same as the single table state. So you can just check for rows:
if ($te->rows) { ... }
Let me know if that doesn't work for you.
Cheers, Matt
Joseph Alotta wrote:
Greetings,
I am using the TableExtracter and it bombs in the line marked with ">>" when it don't match headers for the table. I would like to check to see if it matched, but I don't know what to check. Can someone please help me.
my $html = get($url) || warn "Can't fetch $url\n"; print "$string\n";
my $te = new HTML::TableExtract( headers => ["1 Year", "3 Year", "5 Year", "10 Year"] );
$te->parse($html);
>> my $p = ($te->rows)[0];
my ( $one, $three, $five, $ten) = @$p;
Joe Alotta