kireol has asked for the wisdom of the Perl Monks concerning the following question:

Hi all, I am still learning perl. I am having trouble figuring out the complexities of perl variables and how the referencing works. I've tried reading the perldoc on reftut. Any help here would be appreciated.

I have the following code and I need to pull out the amount in the tables....
----------------------------------------------
$tes = new HTML::TableExtract(headers => [qw(Summer)]); $tes->parse($mech->content());

and then I'm trying to figure out how to grab the values....

foreach $ts ($tes->table_states) { foreach $row ($ts->rows) { print $row->[1],"999\n"; } }
----------------------------------------------
Summer appears in 2 tables at the same depth. and there are some empty fields as well. The amount will always be in the same position in the tables. Please help
----------------------------------------------
Table (2,10): ^M + ^M $1,485.14^M ^M Table (2,13): ^M ^M $1,623.57^M ^M
----------------------------------------------

20041210 Janitored by Corion: Put CODE tags around code

Replies are listed 'Best First'.
Re: Help with Variables
by gaal (Parson) on Dec 10, 2004 at 21:03 UTC
    When picking up references, your friends are the various data dumping modules. Data::Dumper, Data::Dump::Streamer, YAML, and others. Of these, the first comes installed on your distribution of perl.

    Then the trick is to get used to the (simple, when you wrap your head around it) ways of taking and unraveling a reference. Don't worry, you'll get there.

Re: Help with Variables
by tall_man (Parson) on Dec 10, 2004 at 21:02 UTC
    In the documentation for HTML::TableExtract, it says: All other columns are ignored: think of it as vertical slices through a table. In addition, TableExtract automatically rearranges each row in the same order as the headers you provided.

    Since you extracted only one column header, I expect the data will be found at $row->[0], not $row->[1].

Re: Help with Variables
by Joost (Canon) on Dec 10, 2004 at 20:52 UTC
    Your code looks ok, depending on the input, but I don't really see what that data in the last part of your post is. It certainly doesn't look like an HTML table.

    Could you update your post to include input and (expected) output? It would help us resolve your problem.

    Please don't forget to use <code> tags to mark your code.

    Joost.