You don't fully explain all the details, but here are some suggestions - I'm sure you'll get lots more too from more learned monks.

Starting from the above you can get rid of most of your CGI parsing code which will make your script a lot easier to work with. Your script will start to look more like:

#!/usr/bin/perl -wT # news.pl use Strict; use CGI qw(:standard);

Now that you have done that, the CGI moudule will take care of all your form processing, for example to put the value of the foo paramater into a variable you can use: my $bar = param("foo"); much easier than doing it yourself.

CGI also handles the output too, so to print the HTTP header, and your HTML you can now do something more like:

print header(), start_html, hr, h1("Heading"), hr, end_html;

and this will send the following to the browser:

Content-Type: text/html; charset=ISO-8859-1 <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.0//EN" "http://www.w3.org/TR/xhtml-basic/xhtml-basic10.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en-US"><head><title>U +ntitled Document</title&gt; </head><body><hr /><h1>Heading</h1><hr /></body></html>

This will no doubt make your life a lot easier... If you want to find out more, browse this site you may wish to look at some of the books in the Book Reviews section, have a look at Writing CGI Applications with Perl amongst others.

Anyhow my comments are a small start, others will no doubt add more.

Good luck.


In reply to Re: Writing a simple posting script which can be used via the web by ajt
in thread Writing a simple posting script which can be used via the web by Anonymous Monk

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.