I started using this as the basis of my own solution (thanks!), but I realized the problem space was more complex than simply processing each TD tag. When the file is updated from the CGI environment, I need to match up the form fields from the CGI form with the TD tags. That could be accomplished by numbering the form fields in the order they appear in file. Not so hard.

This is harder: In the old script, I had a nice trick to figure out what size to make the form input field (and whether to make it a text box or a textarea). I based the size on the largest piece of content in a particular column. To this, I had to read through the whole table once before I processed the first TD cell.

After some contemplation, I realized that all I needed to do to fix the old script was to simply remove any newline characters that appear in the form. Since I control the template file, I could already make sure that each TD appeared on a single line, that the HTML was complete enough, etc.

This quick fix is almost unfortunate because in many other regards, the script could use several "good style" updates, including: using CGI.pm, using 'strict', seperating the code from the design with a template. It was last worked on almost 2 years ago. I've learned a lot since then. :)

Despite it's poor style, it's been a useful tool over the years. Perhaps I'll get around to genericizing it, documenting it and releasing it into the wild.

-mark


In reply to Re: Re: Using HTML::Parser to edit files in place by markjugg
in thread Using HTML::Parser to edit files in place by markjugg

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.