|
CSCI A348/548
|
Here's a quick plan and summary context for this lecture and the next, including a brief perspective on the following two weeks.
Last time we developed a simple hello script. Its output was not sophisticated.
The output was coded in HTML, and the only difference between it and a similar (identical, in fact) file was that the output of the script had to start with a label that was specifying what type it had:
followed by a blank line (hence theContent-type: text/html
\n\n following it). In lab we extended this script to allow for variable output from it.
We also started talking about the misterious printenv you found in your cgi-bin directory.
The purpose of today's lecture is to provide enough information to allow you to implement a script with the following functionality for your next assignment.
Here's the prototype for assignment #2.
Here's what we will need to get this done:
telnet to our server.
printenv does and what it prints.
printenv. Once that is done, we will move to:
Then we can define CGI, and implement a function readParse.
Then we can introduce CGI.pm, which is the de facto standard for CGI processing with Perl.
Then we can ask ourselves if CGI is any good, and if there's anything else that does the same thing, or more, or better.
And before we move to competing server-side technologies, we'll take a second look to client-side processing, investigating ways in which HTML can be extended. This will lead us into JavaScript, and we will implement a shopping cart application, that will use JavaScript on the client side and CGI with Perl on the server side.
Then we'll be ready to look into other server side technologies such as Java servlets, JSP, or PHP.
So now we will start developing the helper program for the first part of the next assignment.
#!/usr/local/bin/perl
print "Content-type: text/html\n\n";
print "<html><body><pre>";
$string = $ENV{'QUERY_STRING'};
foreach $key (keys %ENV) {
if ($key eq $string) {
print $key, " --> ";
print $ENV{$key}, "\n";
} else {
print qq{<a href="/cgi-bin/printenv?$key">$key</a>}, "\n";
}
}
print "</pre></body></html>";
Try the script above.
The Learning Perl book is on reserve at Swain for A348.
In what follows we will be
going over the quiz questions and justify the correct answers
thus reviewing several aspects of Perl. When we are done we need
to move into CGI.pm.
A348/A548.