Chapter 11: CGI/Perl Part I
pages 1 - 22
Webpages Can Be
Dynamic Technologies
- CGI: Common Gateway Interface
- ASP: Active Server Pages
- Java Applets
Perl
A Script on Esus
- The script.
- Notice the .cgi extension of the file.
- Notice the permission settings required.
- Here is the source code.
- A web page that demonstrates
linking to the script.
Running the Script from the Command Line
- To test a script for syntax errors: perl -c script1.cgi
- To execute a script: perl -w script1.cgi
Sending Data to a CGI Script
- View the source code of this
example
and look at the browser address bar.
- View the source code of this
example
and look at the browser address bar.
- Notice the key/value pairs.
- Notice how to send a blank character.
Parsing Data in a CGI Script
- Run this
example
and then look at the
source code.
- Run this
example.
- The CGI.pm (perl module) is part of the Standard Perl distribution.
- qw is the quote word function.
- :standard is an import tag that tells Perl to import just
the standard features of CGI.pm.
- -debug is a pragma that tells the script to pause
to allow information to be entered from the keyboard.
- Notice the param(key) function in the script.
- Notice some of the possibilities of the print
function in the script.
Sending Multiple Data
- <a href="http://whatever?key1=value1&key2=value2">
- Notice the &.
Monday Exercise
- Work Review Questions 1 - 15 from Chapter 11. 3 points.
- Work a modified version of Exercise 11-4. Translate any five
English words into two languages of your choice. Get the Perl
script to run on esus. 5 points.
Submit the answers to the above questions via memory stick
before lab ends.
Tuesday Exercise
I will give you the URL of an e-commerce site. Answer
the following questions during lab today
regarding this site. At the end of
the lab, place your answers on the memory stick.
10 points.
- What type of markup language does the homepage use?
- Does the homepage validate? If not, mention the most
common type of error.
- List the web programming technologies that the homepage uses.
- There is some glaring redundancy in the code that
produces the homepage. Describe how
this redundancy can be fixed.
- List the various form elements and their type that appear
on the homepage.
- Explain at a high level where the moving image comes from.
- Describe in detail one interesting thing that you learned
by studying the page.
- Where does the current weather information come from?
- Besides things alluded to in previous questions, describe one
other way in which the page can be improved.
- What company designed the page? Describe one interesting
thing about this company.