Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Re: Problems with TableExtract

by mojotoad (Monsignor)
on Jan 10, 2006 at 05:29 UTC ( #522094=note: print w/replies, xml ) Need Help??

in reply to Problems with TableExtract

The cannonical form is the second example you give, e.g.
my $te = HTML::TableExtract->new( headers => [qw($service $arrival $tr +ansit)] ); $te->parse($html_string); foreach my $row ($te->rows) { foreach my $cell (@$row) { print $cell; } }
The old style of dealing directly with the arrays of rows is no longer supported (though each row is still indeed an array).

I note that in your example code, you're not setting $html_string beforehand. That could be a paste-o, but make sure you're using strict to catch that kind of thing.

Having said all that -- if it's still not working, which version of HTML::TableExtract are you using?

Matt (author of said module)

Replies are listed 'Best First'.
Re^2: Problems with TableExtract
by suaveant (Parson) on Jan 10, 2006 at 05:53 UTC
    Cool module :)

    I looked at my version and I have 1.08, for simplicity I had just gone with the debian version, I guess its a bit behind.

    I wonder if he did the same as me, has an older version but was looking at the docs on :)

                    - Ant
                    - Some of my best work - (1 2 3)

      With 1.08, try this:
      my $te = HTML::TableExtract->new( headers => [qw($service $arrival $tr +ansit)] ); $te->parse($html_string); my $ts = $te->first_table_state_found; foreach my $row ($ts->rows) { foreach my $cell (@$row) { print $cell; } }

      If it's actually capturing tables, that should work. (you can monitor, in detail, whether tables are being captured by setting the 'debug' parameter to varying levels (1..7) in the new() constructor).

      Let me know what happens,

      And yes, part of this is my fault. As I phased out the array-only functionality (i.e. the tables() method) I eventually aliased that to the table_states() method and it has caused confusion. I should have waited longer before ressurecting the tables() method, if at all. (in my defense, it is what I would have called the table_states() method to begin with, but in a very very early version of the module I used tables() to return the arrays. Ah well.)


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://522094]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (3)
As of 2020-07-08 04:28 GMT
Find Nodes?
    Voting Booth?

    No recent polls found