From a quick perusal of HTML::Manipulator, it seems that it presupposes you have some HTML in a certain format: either with id tags (by definition these are unique) or comment markers. If you have that, great. If not, and you can't get there, then you'll have to look for another way.

Generally, I can get away with making all my HTML actually XHTML-compliant. Which then means I can whip out my favourite swiss-army knife: XML::Twig. If your HTML already is XHTML, then this becomes really easy - the complicated part will be coming up with the XPath, but that shouldn't be too hard ... something like //div[string()="nothing"] is my guess. The get_xpath function will return all the tag objects at once, and you can just loop through, change the text for each one (set_text), and print it all back out.

Otherwise, you'll probably have to roll your own with HTML::Parser...


In reply to Re: Editing HTML files by Tanktalus
in thread Editing HTML files by spivey49

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.