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!


In reply to Re: admin. g-book by Hero Zzyzzx
in thread admin. g-book by deriwana

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.