use HTML::Parser; sub extract_html_text { my $html = shift; my $text = ''; HTML::Parser->new( api_version => 3, text_h => [ sub { $text .= "@_"; }, "dtext" ] )->parse( $html )->eof; $text }