Daniel,

Try using a switch statement (even though Perl doesn't officially have a
switch statement).  Here's some code below.....let me know if you have
questions.

#!/usr/bin/perl

use HTML::TableExtract;

@headers = ("kevin", "sorry", "larry");

foreach $a (@headers){

        SWITCH: {

                if($a =~ qw/sorry/) { $sorry = 1; last SWITCH; }
                if($a =~ qw/kevin/) { $kevin = 1; last SWITCH; }
                if($a =~ qw/larry/) { $larry = 1; last SWITCH;}
                $nothing = 1;
        }
}

    $te = new HTML::TableExtract( headers => [@headers] );
    $te->parse($html_string);
    # Examine all matching tables
    foreach $ts ($te->table_states) {
      print "Table (", join(',', $ts->coords), "):\n";
      foreach $row ($ts->rows) {
      $mRow = "@$row";
      $mRow =~ s/.*\>//g;
      #$mRow =~ s/[^.\d\s]//g;
      @webValues = split/\s+/, $mRow;
      print join(' ', $mRow), "\n";
      }
      undef @headers;
    }

Hope this helps,
Kevin
----- Original Message -----
From: "Daniel Falkenberg" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, February 19, 2002 7:07 PM
Subject: HTML::TableExtract


Hi all,

At the moment I am working with HTML::TableExtract.  I must say that I
am having alot of fun with it and most of it is working really well.
What I am looking for is some ideas on how I can go about the
following...

Basically I have my own CGI/Perl page that a user enters some
credentials after these are entered the form data is then sent off to
another WWW site that does 'stuff' with the data.  Of coarse after this
is sent and maniputlated at the other end the required data from the
remote WWW site is returned.  Now at the moment the user can enter data
and depending on the data there is a possbile 4 outcomes that the remote
WWW site will return.

What I would like to use (but am very happy to hear other suggestions)
is an if elsif statement that can get this returned data.  Lets say the
user enters a phone number that checks against 'stuff'.  If the phone
number doesn't exist on the remote WWW site then there is one returned
outcome.  If the phone number does exist and can successfully get a
service with the provider then there is another outcome (2)... and so
on.

Here is the code I have so far...

    @headers = qw /sorry/;
    $te = new HTML::TableExtract( headers => [@headers] );
    $te->parse($html_string);
    # Examine all matching tables
    foreach $ts ($te->table_states) {
      #print "Table (", join(',', $ts->coords), "):\n";
      foreach $row ($ts->rows) {
      $mRow = "@$row";
      $mRow =~ s/.*\>//g;
      #$mRow =~ s/[^.\d\s]//g;
      @webValues = split/\s+/, $mRow;
      print join(' ', $mRow), "\n";
      }
      undef @headers;
    }

Now the code works OK only if the out come in the headers is sorry :).
Does any one know how I would go about checking to see if the headers
returned on a successfull page were not sorry but other words.

Kind Regards,

Dan

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to