If you're adamant about doing this in perl, one of the existing html parser modules will prevent re-inventing the wheel in terms of html parsing, so the parsing will be more robust.
the hardest line to type correctly is: stty erase ^H
Comment on Re: Help reading file, stripping tags, writing new file