#!/usr/bin/perl -w use strict; use English; use warnings; use HTML::Parser; { package JavascriptIsBad; use base 'HTML::Parser'; my $result; my $skipping = 0; sub start { my($self, $tagname, $attr, $attrseq, $origtext) = @_; if (lc($tagname) eq 'script') { $skipping = 1; } $result .= $origtext unless $skipping; } sub end { my($self, $tagname, $origtext) = @_; $result .= $origtext unless $skipping; if (lc($tagname) eq 'script' and $skipping) { $skipping = 0; } } sub text { my($self, $origtext, $is_cdata) = @_; return if $skipping; $result .= $origtext; return; } sub result { $result } } my $p = JavascriptIsBad->new; $p->parse(< tag! It's important!"); This is just some text. EOF print 'Result: ', $p->result, "\n";