in reply to Replacing text NOT in an HTML tag

Using a HTML::Parser and only running the regex against the text parts is probably the easiest way of achieving this.