Professional Web Applications Themes

Rookie: HTML::TableExtract test will not print - PERL Miscellaneous

Hello, This script will not generate any output within the foreach loop. No errors or anything. $te tests ok with a hash. I can't figure it out. My sample .html file consists of 1 table (depth = 0, count = 0). Using perl 5.8/Suse 8.0 Thanks in Advance =========================== #!/usr/bin/perl use warnings; use strict; use HTML::TableExtract; my $target = "op2.html"; my $te; my $ts; my $row; if (-e $target) { print "File Exists\n"; } $te = new HTML::TableExtract( depth => 0, count => 0 ); $te->p($target); print "We are here\n"; foreach $ts ($te->table_states) { print "Table found at ", join(',', ...

  1. #1

    Default Rookie: HTML::TableExtract test will not print

    Hello,

    This script will not generate any output within the foreach loop. No errors
    or anything. $te tests ok with a hash. I can't figure it out.

    My sample .html file consists of 1 table (depth = 0, count = 0). Using perl
    5.8/Suse 8.0

    Thanks in Advance
    ===========================
    #!/usr/bin/perl

    use warnings;
    use strict;
    use HTML::TableExtract;

    my $target = "op2.html";
    my $te;
    my $ts;
    my $row;

    if (-e $target) { print "File Exists\n"; }

    $te = new HTML::TableExtract( depth => 0, count => 0 );
    $te->p($target);

    print "We are here\n";

    foreach $ts ($te->table_states) {
    print "Table found at ", join(',', $ts->coords), ":\n";
    foreach $row ($ts->rows) {
    print " ", join(',', $row), "\n";
    }
    }
    ============================


    sdfgsd Guest

  2. #2

    Default Re: Rookie: HTML::TableExtract test will not print

    sdfgsd <com> wrote:
     


    Your code looks OK to me. Must be the data (that we weren't given).


    --
    Tad McClellan SGML consulting
    com Perl programming
    Fort Worth, Texas
    Tad Guest

  3. #3

    Default Re: Rookie: HTML::TableExtract test will not print

    > Your code looks OK to me. Must be the data (that we weren't given).

    Thanks for the follow-up. I'm hoping I can get this to work because this
    looks like a phenomonal tool...as opposed to having to write a new state
    machine/pr :-)

    The .html file looks like this:
    =============================
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

    <html>
    <head>
    <title>Untitled</title>
    </head>

    <body>
    <table>
    <tr>
    <td>1</td>
    <td>2</td>
    <td>3</td>
    </tr>
    <tr>
    <td>4</td>
    <td>5</td>
    <td>6</td>
    </tr>
    <tr>
    <td>7</td>
    <td>8</td>
    <td>9</td>
    </tr>
    </table>

    </body>
    </html>


    sdfgsd Guest

  4. #4

    Default Re: Rookie: HTML::TableExtract test will not print


    "Sam Holden" <cs.usyd.edu.au> wrote in message
    news:cs.usyd.edu.au... 
    >
    > Slurps the entire file into $target.
    >
    > See "perldoc perlvar" and the section on $/ for information on why.
    >
    > The block and local are used to limit the effect of the
    > change to $/ (it is set to undef by the local) to just the
    > read into $target.[/ref]

    Well put. This would have taken me a long time to internalize. Thank you.


    sdfgsd Guest

Similar Threads

  1. Replies: 1
    Last Post: May 16th, 05:24 AM
  2. HTML::TableExtract
    By rl9022 in forum PERL Modules
    Replies: 0
    Last Post: October 12th, 12:30 AM
  3. Please help me with HTML:TableExtract
    By Bjorn Hermans in forum PERL Modules
    Replies: 1
    Last Post: September 21st, 01:49 AM
  4. Replies: 1
    Last Post: July 15th, 02:02 PM
  5. HTML::TableExtract Simple question
    By A. Sinan Unur in forum PERL Miscellaneous
    Replies: 4
    Last Post: June 30th, 07:13 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139