in reply to Re^2: Parsing HTML
in thread Parsing HTML
my @anchors = $t->look_down(_tag => q{a}); my @hrefs; for my $anchor (@anchors){ if ($anchor->as_text eq q{NEXRAD Level III}){ push @hrefs, $anchor->attr(q{href}); $anchor->replace_with_content; } } print qq{$_\n} for @hrefs;
An href is attribute of an HTML element, hence $anchor->attr(q{href}) :-)HAS.FileAppSelect?datasetname=7000
Have a look at the HTML::Element docs to see what the look_down, as_text, attr and replace_with_content methods do.
update
heh! Looking back at your original question I saw
I want to remove the href...and I read that as removing the anchor tag from the HTML. :-)
Did you mean you wanted to get/extract the hrefs and store them in an array? If so you don't need the
line. I'll get there in the end. :-)$anchor->replace_with_content;
|
|---|