P
Peter Jamieson
#I want my script to parse HTML tables such as the one included below:
#!/usr/bin/perl -w
use strict;
use warnings;
my $moggy = '<TABLE WIDTH=100% BORDER=0 CELLSPACING=0 CELLPADDING=0>
<TR>
<TD WIDTH=12% ALIGN=LEFT class=Tipster> RADIO TAB</TD>
<TD WIDTH=14% class=Tips> 3-2 </TD>
<TD WIDTH=16% ALIGN=LEFT class=Tipster></TD> <TD WIDTH=14% class=Tips></TD>
<TD WIDTH=14% ALIGN=CENTER></TD> <TD WIDTH=10% class=TrackCond> 520M</TD>
<TD WIDTH=10%
class="TrackCond">FINE</TD> <TD WIDTH=10% class="TrackCondR">GOOD</TD> </TR>
</TABLE>';
# I tried this
$_ = $moggy;
my ($d,$e,$f);
$d=''; $e=''; $f='';
($d,$e,$f) = /TrackCond(.*)<\/TD>/g;
print "d ",$d," e ",$e," f ",$f,"\n";
This produces for $d
and no value for $e or $f
I would have expected
$d to be: > 520M, $e to be: ">FINE and $f: to be R">GOOD
Can anyone suggest why I don't get this and where I am going wrong here?
Any comments appreciated!
#!/usr/bin/perl -w
use strict;
use warnings;
my $moggy = '<TABLE WIDTH=100% BORDER=0 CELLSPACING=0 CELLPADDING=0>
<TR>
<TD WIDTH=12% ALIGN=LEFT class=Tipster> RADIO TAB</TD>
<TD WIDTH=14% class=Tips> 3-2 </TD>
<TD WIDTH=16% ALIGN=LEFT class=Tipster></TD> <TD WIDTH=14% class=Tips></TD>
<TD WIDTH=14% ALIGN=CENTER></TD> <TD WIDTH=10% class=TrackCond> 520M</TD>
<TD WIDTH=10%
class="TrackCond">FINE</TD> <TD WIDTH=10% class="TrackCondR">GOOD</TD> </TR>
</TABLE>';
# I tried this
$_ = $moggy;
my ($d,$e,$f);
$d=''; $e=''; $f='';
($d,$e,$f) = /TrackCond(.*)<\/TD>/g;
print "d ",$d," e ",$e," f ",$f,"\n";
This produces for $d
class="TrackCondR">GOOD520M</TD> <TD WIDTH=10% class="TrackCond">FINE</TD> <TD WIDTH=10%
and no value for $e or $f
I would have expected
$d to be: > 520M, $e to be: ">FINE and $f: to be R">GOOD
Can anyone suggest why I don't get this and where I am going wrong here?
Any comments appreciated!