deriwana has asked for the wisdom of the Perl Monks concerning the following question:

in response to the post "admin. guestbook" Sorry for my vagueness before, I'll try to clear some things up..
The file that the guestbook writes to is more or less a flat-file database WITHOUT delimiters, so there isn't a way to single out entries unless a name, address, or zipcode-query is done to point to a certain area of the file to be edited.
Ultimately, I would like the script to be able to edit the flat-file html page thru an admin. page like the one submitted by "Tachyon"..(see "admin. guestbook")

....just the ability to edit the contents of a flat-file database(which is lacking obvious delimiters) over the web. Here is the guestbook script that creates the flat-file: http://204.33.180.159:8080/guest.txt

P.S., keep in mind that the guy who wants this is not very web-savy, and doesn't want to edit the entries in an html format.
Thanks to everyone who submitted a response before.

Replies are listed 'Best First'.
Re: admin. g-book
by Hero Zzyzzx (Curate) on Jun 15, 2001 at 22:53 UTC

    Yucky, yucky code there in guestbook.txt. . .

    There probably isn't going to be an easy way to edit the guestbook file. Probably the easiest, messiest, way to do it would be to read the whole file in, then print it out HTML escaped into a <textarea></textarea> part of a form. This will put the HTML into the textarea, too. This will also be really slow if the guestbook gets large. Make sure the form "POSTS" and doesn't "GET", otherwise you won't be able to shuffle around that much data.

    You really should use CGI.pm to parse form data, it also has very good HTMLescape and unescape functions.

    After your client does the edits in the textarea, write the whole file out again after the POST. Be sure to lock the file. There are many problems with this. If the transfer gets stopped, mid-stream, you could lose data. Plus, with a large guest book this will be slow.

    There are better ways to do this, but not many that I can think of that wouldn't involve you cleaning up the data format.

    I'm sure other monks would have a better way.

    Update: I didn't see the other thread. What I suggested was already put out by tachyon. deriwana you really should post followup questions in the same thread in the future. Thanks!