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

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

  • Comment on Re: Re: Using HTML::Parser to edit files in place