in reply to using HTML::TreeBuilder to collect data for populating variables

I'm sure this code really clever...however hard to figure out exactly what it does as the sub uses some globals as well as parameters passed to it, and also invokes some (undocumented) look_down and as_text subs attached to hash structures.
from a modular code design and maintainability perspective not great code to work with.
i suggest you contact the author of the code, rather than putting the named author's code up for review/explanation in this separate post.
the hardest line to type correctly is: stty erase ^H
  • Comment on Re: using HTML::TreeBuilder to collect data for populating variables

Replies are listed 'Best First'.
Re^2: using HTML::TreeBuilder to collect data for populating variables
by wfsp (Abbot) on Aug 04, 2010 at 06:55 UTC
    hi aquarium,

    I suggested starting a new thread. The previous thread, collect data from web pages and insert into mysql had made some progress and I thought the next step warranted a new thread (we had got down to Re^11). Tackle a broad question in chuncks rather than in one go. I still think it was reasonable advice but perhaps a bit more explanation and some working code would have helped. :-)

    As SteinerKD has indicated $t is an HTML::TreeBuilder object and should have been passed to the sub. H::TB returns HTML::Element objects and it is there that $t->look_down() and $t->as_text are documented.

    It's not clever code but may well be hard to figure out and not great to work with. With hindsight it might be more appropriate to use something like HTML::TableExtract. In the previous thread we already had a H::TB object and that was pressed into service.

Re^2: using HTML::TreeBuilder to collect data for populating variables
by GrandFather (Saint) on Aug 04, 2010 at 10:21 UTC

    Actually the code is fairly standard. However it does use a module which leverages another module to get some serious work done. The HTML::TreeBuilder documentation specifically refers to the HTML::Element documentation and makes it clear in several places that you are dealing with objects.

    True laziness is hard work
Re^2: using HTML::TreeBuilder to collect data for populating variables
by SteinerKD (Acolyte) on Aug 04, 2010 at 01:22 UTC

    It uses HTML::TreeBuilder and it was the original code writer that suggested I made a new topic as the old one where the sub comes from was getting a bit large.


    Sorry for wasting your time, I figured it out.

    The $t variable was rather essential as it contained the content the TreeBuilder had created and I wanted to navigate. When feeding that variable with coordinates it returned exactly what I was expecting it to!

    Now I need to figure out how to use the same code to grab the variable length list data from the pages as that gives a moving target.