Hi All,

I am having a hard time extracting data from an HTML file I am
downloading from the web. What I want to do is extract the name and jersey
number from a soccer web page.

Here is what I have tried:

#!/usr/bin/perl
use strict;
use warnings;
use LWP::UserAgent;
use HTML::TreeBuilder;
my $ua = LWP::UserAgent->new;
 
my $url = 'http://www.coastsoccer.com:443/2004/P4619.HTM'; 
my $req = HTTP::Request->new(GET => "$url");
 
# send request
my $res = $ua->request($req);

# check the outcome
unless($res->is_success) {
      warn "Couldn't get $url: ", $res->status_line, "\n";
      return;
    }

my $tree = HTML::TreeBuilder->new_from_content($res->content);
   $tree->eof;

   my $realtable = $tree->look_down(
                         '_tag', 'table',
                   sub {
                   my $table = $_[0]->look_down('_tag','table');
                   return 1 if $table->attr('cellpadding') =~ m{/6/};
                   return 0; # otherwise bad
                   }
             );   
And ther error is:
F:\scripts>testxxx.pl
Use of uninitialized value in pattern match (m//) at F:\scripts\testxxx.pl line 27.

It seems that it does not recognize the ceelpadding attr (which should be 6)
Can anyone tell me what Iam doing wrong?

Thanks

Ron Hill

Reply via email to