Sounds like you need an HTML Parser. Hmm, HTML::TokeParser?
In reply to Re: Removing Javascript by chromatic in thread Removing Javascript by Mur