in reply to inserting html tags after X characters
Don't try to parse HTML with simple regular expresseions. I recommend to use something like HTML::TreeBuilder to parse HTML correctly and the do your thing on the tree. This way you can be sure not to destroy valid HTML and you can for example notice BR,HR,P etc. elements to make your counter clever...
--
|
---|