use HTML::Parser; my $found = 0; sub callback { my($tagname, $text) = @_; if($tagname and $tagname eq 'td') { if(not $found) { # start tag. $found = 1; } else { # end tag. $found = 0; } return; } print $text and return unless $found; # If you're here, then the markup is within the td tags. } my $p = HTML::Parser->new(api_version => 3, default_h => [\&callback,'tagname, text']);