#!/usr/bin/perl -w use strict; use English; use warnings; use HTML::TokeParser; my $doc = < tag! It's important!"); This is just some text. EOF my $p = HTML::TokeParser->new(\$doc); my $result; my $skipping = 0; while (my $tok = $p->get_token) { if ($tok->[0] eq 'S') { if (lc($tok->[1]) eq 'script') { $skipping = 1; } elsif (!$skipping) { $result .= $tok->[-1]; $result .= $p->get_text; } } elsif ($tok->[0] eq 'E') { if (lc($tok->[1]) eq 'script') { $skipping = 0; } elsif (!$skipping) { $result .= $tok->[-1]; $result .= $p->get_text; } } elsif (!$skipping) { $result .= $tok->[-1]; $result .= $p->get_text; } } print 'Result: ', $result, "\n";