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> </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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |