use HTML::TokeParser::Simple; my $p = HTML::TokeParser::Simple->new (\*DATA) or die; my $in_small = 0; while (my $token = $p->get_token) { if ($token->is_start_tag('small')) { $in_small++; } elsif ($token->is_end_tag('small')) { $in_small--; } elsif (not $in_small) { print $token->as_is; } } __END__ hello world

hello world

Did you know that this is small?