in reply to =~ and substitutions

It's also printing <p> and </p> to browser while I'm trying to pull back only the text rather than the codes.

Where, precisely, do you think $1 is getting set? If your answer is anything other than "oops", look again.

Also, if you're emitting stuff into a <textarea> block, you need to escape certain HTML entities, notably as '<', '>', and '&'.