Jet another way, using
HTML::Tree:
Please note that this doesn't handle the unescaped closing script tag in document.write. I'd suggest running tidy on the input before passing it to the parser.
#!/usr/bin/perl -w
use strict;
use HTML::Tree;
my $doc = <<EOF;
<html>
<head>
<script language="Javascript">
document.write("Don't forget your </script> tag! It's important!
+");
</script>
</head>
<body>
This is just some text.
</body>
</html>
EOF
my $root=HTML::TreeBuilder->new();
$root->parse($doc);
$root->eof;
foreach my $n ($root->descendants) {
next unless $n->tag; # skip text nodes
$n->delete if $n->tag eq 'script';
}
print $root->dump; # prints structure
print $root->as_HTML # prints as HTML
--
#!/usr/bin/perl
for(ref bless{},just'another'perl'hacker){s-:+-$"-g&&print$_.$/}