Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Re: Using HTML::Parser extract text from tables

by zzspectrez (Hermit)
on Jan 18, 2001 at 12:07 UTC ( [id://52726]=note: print w/replies, xml ) Need Help??


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

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>

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (5)
As of 2024-04-19 12:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found