#!/usr/bin/perl -- use strict; use warnings; use HTML::TreeBuilder; my $html = <<'__HTML__'; Open this result in new windowANCHOR TEXT Two clues for the price of one __HTML__ { my $h = HTML::TreeBuilder->new_from_content($html); for my $link ( $h->look_down( _tag => q{a}, href => 'http://www.yahoo.com' ) ) { print $link->attr('href'),"\n"; my $text = $link->as_trimmed_text; unless ($text) { $text = join ' ', map { $_->attr('alt') } $link->look_down( alt => qr/^.+$/ ); } print "$text\n\n"; } ## end for my $link ( $h->look_down...) } __END__