HTML::Scrubber lets you allow only selected tags. I lifted the following from the pod (slightly modified):
#!/usr/bin/perl -w
use HTML::Scrubber;
use strict;
my $html = q[
<style type="text/css"> BAD { background: #666; color: #666;} </style>
<script language="javascript"> alert("Hello, I am EVIL!");
</script>
<HR>
a => <a href=1>link </a>
br => <br>
b => <B> bold </B>
u => <U> UNDERLINE </U>
];
# only allow the following tags
my $scrubber = HTML::Scrubber->new( allow => [ qw[ p b i u hr br ] ] )
+;
print $scrubber->scrub($html);
__END__
Output:
<hr>
a => link
br => <br>
b => <b> bold </b>
u => <u> UNDERLINE </u>
style, script and links are gone.