CGI.pm
offers a rich set of
functions for creating HTML forms
and
a simple interface for parsing and interpreting query
strings passed to CGI scripts.
mod_perl
isa persistent Perl interpreter embedded in a
(Apache) web server.
cgi-lib
The cgi-lib.pl library has become the de facto standard library for
creating Common Gateway Interface (CGI) scripts in the Perl language.
-----------------------
The following Material is taken from the original page by
Steven E. Brenner:
cgi-lib.berkeley.edu/index.html#doc
Please consult the original if still available.
-----------------------
Example:
This is the HTML source for the form:
Pop Quiz:
What is thy name:
What is thy quest:
What is thy favorite color:
What is the weight of a swallow: African Swallow or
Continental
Swallow
What do you have to say for yourself
Press to submit your query.
This is the Perl source for the file "simple-form.cgi"
hat processes the form:
#!/usr/local/bin/perl
# $Header: /cys/people/brenner/http/docs/web/RCS/simple-form.cgi,v 1.4 1996/03/29 22:07:56 brenner Exp $
# Copyright (C) 1994 Steven E. Brenner
# This is a small demonstration script to demonstrate the use of
# the cgi-lib.pl library
require "cgi-lib.pl";
MAIN:
{
# Read in all the variables set by the form
&ReadParse(*input);
# Print the header
print &PrintHeader;
print &HtmlTop ("cgi-lib.pl demo form output");
# Do some processing, and print some output
($text = $input{'text'}) =~ s/\n/\n /g;
# add 's after carriage returns
# to multline input, since HTML does not
# preserve line breaks
print < $text
ENDOFTEXT
# If you want, just print out a list of all of the variables.
print "
And here is a list of the variables you entered...
";
print &PrintVariables(*input);
# Close the document cleanly.
print &HtmlBot;
}
The simple-form.html and simple-form.cgi have been combined into a
single script.