in reply to Removing Javascript

It sounds like you're looking for a regex. 99% of the time slicing up HTML with regexes is the wrong thing to do. I would try looking into HTML::TokeParser or similar modules to do this.

If you're using XHTML you can use an XML parser such as XML::Simple or XML::Parser but that may be overkill.