in reply to Re^3: anchor text match
in thread anchor text match

#!/usr/bin/perl -- use strict; use warnings; use HTML::TreeBuilder; my $html = <<'__HTML__'; <a href="" target=_blank><img src="" alt="Open this result in new window">ANCHOR TEXT</a> <a href="" target=_blank><img src="" alt="Two clues for the price of one"></a> __HTML__ { my $h = HTML::TreeBuilder->new_from_content($html); for my $link ( $h->look_down( _tag => q{a}, href => 'http://www.yaho' ) ) { 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__

The output is :; ANCHOR TEXT; Two clues for the price of one

But the desired output is :; ANCHOR TEXT; IMAGE (indicating no anchor text and also presence of img tag within anchor tag )

Any ideas?