Return to the archive index

Re: Idiot's Guide to Perl CGI problems

From: ccgreg@gold.missouri.edu (Greg Johnson )
Date: 21 Jun 1996 18:33:38 GMT
Newsgroups: comp.infosystems.www.authoring.cgi

This is sort of covered by Tom's points, but I've phrased it explicitly in
showing a model CGI script to Learners of Perl:

 # The First Thing to do in any Perl CGI Script:

 open(STDERR,'>&STDOUT'); 
 $| = 1;

	# This causes error messages to display with 
	# standard output, as soon as they occur.
	# Otherwise CGI run-time errors don't display.

 # The Second Thing to do in any Perl CGI Script:

 print "Content-type: text/html\n\n";

	# Every browser expects a header like this one.
	# If we delayed sending this, and we generate an
	# error, this error message would be the first
	# thing to print--as a "malformed header".

 # Now we can do our intended tasks.

The whole example's in: http://www.phlab.missouri.edu/perl/demo/

From John's Useful Posting Archive (JUPA)
Maintained by John Callender
John's Home Page

Archive created with babymail