in reply to Is this the best way to use HTML::TreeBuilder to bold text in an HTML document?

This is an interesting question. My quick and dirty suggestion would that instead of using the module you could simply do something like this:
while ( <DATA> ) { if (/perl/) { s#(\W|\s+)(perl)(\W|\s+)#$1<b>$2</b>$3#i if !/<title>/; } print; }
Not knowing the sensitivity of the data we are dealing with I would say this is a simpler way and much less code to maintain. There may also very well be content outside of the body tag that you don't want, in which case the above quick and dirty example starts be take on more code.
Do you want the Perl in Perlmonks to be bold? If not you you should consider changing the regex in the filter code to something more along the lines of the quick and dirty solution if you feel the HTML::TreeBuilder module works better for your needs.

UPDATE: I added the quick /perl/ match to speed up operations. I also see why my quick solution is dangerous, because it might modify content with in html tags. I ran the solution posted by crazyinsomniac and johannz, both will match words like 'properly', I am not sure what the actual word is that is being matched, but a safer regex will have to be used most likely.
  • Comment on Re: Is this the best way to use HTML::TreeBuilder to bold text in an HTML document?
  • Download Code