S
sjcampbl
Hi and TIA.
Following is a snippet of code which uses HTML::TableContentParser to
pull table data out of an HTML page. I've gotten it to work, but, I'd
like to better understand why/how (particularly the long array/hash
references). I've read the Perllol and Perlref documents, but would
really appreciate a plain language walk-through. Thanks.
my $cServerInventoryURL = '...';
my $cServerInventoryHTML = get $cServerInventoryURL || die "Couldn't
get $cServerInventoryURL";
$p = HTML::TableContentParser->new(); # This seems to assign
a reference handle for the parser object
$tables = $p->parse($cServerInventoryHTML); # This assigns a
reference to an array containing all the tables in the HTML
$t=$tables->[5]; # This
appears to assign a reference to the 6th table object in the HTML page
##### HERE ARE THE REFERENCES IN QUESTION. THEY WORK, I JUST AM NOT
CLEAR WHY #####
for $r (@{$t->{rows}}) {
$cell2=$r->{cells}[1]{data}; #Cell 2 contains server name
$cell9=$r->{cells}[8]{data}; #Cell 9 contains environment list
print "-------------------------\n";
print " cell2 - $cell2\n";
print " cell9 - $cell9\n";
}
Following is a snippet of code which uses HTML::TableContentParser to
pull table data out of an HTML page. I've gotten it to work, but, I'd
like to better understand why/how (particularly the long array/hash
references). I've read the Perllol and Perlref documents, but would
really appreciate a plain language walk-through. Thanks.
my $cServerInventoryURL = '...';
my $cServerInventoryHTML = get $cServerInventoryURL || die "Couldn't
get $cServerInventoryURL";
$p = HTML::TableContentParser->new(); # This seems to assign
a reference handle for the parser object
$tables = $p->parse($cServerInventoryHTML); # This assigns a
reference to an array containing all the tables in the HTML
$t=$tables->[5]; # This
appears to assign a reference to the 6th table object in the HTML page
##### HERE ARE THE REFERENCES IN QUESTION. THEY WORK, I JUST AM NOT
CLEAR WHY #####
for $r (@{$t->{rows}}) {
$cell2=$r->{cells}[1]{data}; #Cell 2 contains server name
$cell9=$r->{cells}[8]{data}; #Cell 9 contains environment list
print "-------------------------\n";
print " cell2 - $cell2\n";
print " cell9 - $cell9\n";
}