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.

In reply to Re: Is this the best way to use HTML::TreeBuilder to bold text in an HTML document? by trs80
in thread Is this the best way to use HTML::TreeBuilder to bold text in an HTML document? by johannz

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.