Giving thought to the problem of nested subs I rewrote it as a module and fixed the error. See the new module. And the following is a test script using it. Just enter the table,row,col and it will print out the text. type quit when done.

If anyone else has any suggestions or improvements for the module I would be glad to hear them.

#!/usr/local/bin/perl -w use strict; use Table; my $table = Table->new; my $content = join '', ( <DATA> ); $table->parse_it(\$content); print "INPUT TABLE,ROW,COL: "; while (my $inp = <STDIN>){ chomp $inp; last if $inp eq 'quit'; my ($x,$y,$z) = split ',', $inp; next unless ($x) && ($y) && ($z); print $table->[$x][$y][$z],"\n" if $table->[$x][$y][$z]; print "INPUT TABLE,ROW,COL: "; } __END__ <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> <html> <head><title>tester.html</title></head> <body> <h1>tester.html</h1> <TABLE> <TR><TD>TABLE 1:ROW 1:COL1</TD><TD>TABLE 1:ROW1:COL2</TD></TR> <TR><TD><TABLE><TR><TD>TABLE 2:ROW1:COL1</TD></TR></TABLE></TD><TD +>TABLE 1:ROW2:COL2</TD></TR> <TR><TD><TABLE><TR><TD><TABLE><TR><TD>TABLE4:ROW1:COL1</TD><TD>TAB +LE4:ROW1:COL2</TD></TR></TABLE>TABLE3:ROW1:COL1</TD></TR></TABLE></TD +></TR> </TABLE> <TABLE> <TR><TD>TABLE5:ROW1:COL1</TD><TD>TABLE5:ROW1:COL2</TD></TR> <TR><TD>TABLE5:ROW2:COL1</TD></TR> </TABLE> <hr> </body> </html>

In reply to Re: Re: Using HTML::Parser extract text from tables by zzspectrez
in thread Using HTML::Parser extract text from tables by zzspectrez

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.