Sooo... My HTML::TableExtract method doesnt seem to be working when I try to parse html strings...

sub Parse{ my $self = shift; my $html_code = shift; my $te = HTML::TableExtract->new( headers => [qw(Severity Advi +sory Synopsis Date)] ); my @args = (); $te->parse($html_code); foreach my $ts($te->tables) { foreach my $row ($ts->rows) { push(@args,("\'".join('\',\'',@$row)."\'\n")); } } return @args; }

That code will not work... I have debugged it in eclipsed and watched the program put the source code correctly into the parser as I would imagine it should. When the dubugger gets to the foreach loops, it skips right over them because the parser did not grab any data from the HTML code to iterate. If I save the same source code as an HTML and use this:

sub Parse{ my $self = shift; my $html_code = shift; my $te = HTML::TableExtract->new( headers => [qw(Severity Advi +sory Synopsis Date)] ); my @args = (); $te->parse_file('blah.html'); foreach my $ts($te->tables) { foreach my $row ($ts->rows) { push(@args,("\'".join('\',\'',@$row)."\'\n")); } } return @args; }

...replacing parse with parse_file and the name of the html file which contains the same code input into parse originally, I get the correct output... For the first code segment which parses an html string, lets assume that the string contains the source code from http://rhn.redhat.com/errata/rhel-server-6-errata-security.html. Am I misunderstanding what an HTML string is ??? What am I doing wrong great Monks of Wisdom???


In reply to Problem with HTML::TableExtract by jayto

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.