use strict; use warnings; use HTML::TreeBuilder; my $html = <(1) Pertussis vaccination: use of acellular pertussis vaccines among infants and young children.
(2) Use of diphtheria toxoid-tetanus toxoid-acellular pertussis vaccine as a five-dose series. (Addendum)
Centers for Disease Control and Prevention - Federal Government Agency [U.S.]. 1997 Mar 28 (revised 2000 Nov; addendum released 2003 Sep 26) . 25 pages. NGC:003288

HTML my $tree = HTML::TreeBuilder->new_from_content ($html); # Get a list of anchors that have an id attribute starting 'GuidelineDataList' my @anchors = $tree->look_down (id => qr/^GuidelineDataList/); for my $anchor (@anchors) { next if ! defined $anchor || ! defined $anchor->parent (); print 'HRef: ', $anchor->attr ('href'), "\n" if defined $anchor->attr ('href'); print 'Text: ', $anchor->parent ()->as_text (), "\n" if defined $anchor->parent (); }