CGI/PERL Tutorial over the Web

Click to go to the PREVIOUS page. Click to go to the INDEX page. Click to go to the NEXT page.

SLIDE #2 THE CGI LIBRARY


In this second slide, we introduce the CGI library.

Using the CGI library, the document format:
print "Content-type: text/html\n\n";
is replaced by a call on the CGI library:
use CGI;
$query=new CGI;
print $query->header;

1. OUR SECOND CGI/PERL PROGRAM EXAMPLE:

#!/usr/local/bin/perl
use CGI;
$query=new CGI;
print $query->header;
print "<html><head><title>A test</title></head>\n";
print "<body>The test was successful.</body></html>";

2. PROGRAM DESCRIPTION:

The first line is a reference to the PERL interpreter.
#!/usr/bin/perl

The second line tells Perl to use the CGI library

The third line creates a $query object. From this object, we can apply
many methods, like $query->header, which prints the document header equivalent 
to print "Content-type: text/html\n\n";

3. PROGRAM EXECUTION:

Access the program by clicking on the following link:
The CGI Library
or, using your browser, type the following URL:
http://www.claywall.com/cgi-bin/CGI/prog02.cgi


© Copyright 2002 International Customized Software Co.