CGI Scripting with Perl
Accelerated Technical Training for Webmasters and Site Programmers
|
Courseware
|
This is a web-based class.
The training materials are at
http://www.keller.com/perlweb.
|
Format
|
- 1 full day
- Emphasis on practical skills.
- Hands-on.
|
Audience
|
This course is for Perl programmers
who wish to construct interactive web sites.
|
Prerequisites
|
Check the boxes for the prerequisites you satisfy.
If you checked all three boxes, you're well-equipped
to get the most from this course!
|
Overview
|
Common Gateway Interface (CGI) is the technical term for
the the mechanism by means of which programs are invoked
on web servers in response to mouse clicks on hyperlinks
by users of browsers.
CGI programs perform such tasks as database updates,
product ordering, survey form completion, and so on.
They also generate new web pages -- termed dynamic web pages
because these pages are created on the fly by the CGI programs.
From the user's perspective, such pages are indistinguishable from
hand-written ("static") ones.
But for the owners and builders of web sites, CGI programs
open vast new possibilities.
This is a technical course for people with Perl programming
experience who wish to apply it to the construction of web sites.
The web as a platform upon which to build and deploy applications
has many advantages:
- It is machine-independent;
your software will run identically on
PCs, Macintoshes, and workstations.
- It is timely;
data and software updates are immediately available.
- It is easy to deploy;
there is no software to distribute, since
your applications run on a server and the client software is
standard.
- It is geographically dispersed;
physical proximity is irrelevant
since the web is indeed World Wide.
- It is easy for users to learn because browsers are intuitive
and already familiar to many.
This course provides the techniques that enable you to gain
all these benefits.
|
Objectives
|
The essential goal of the course is the acquisition of real skills.
Upon completion of this course, you will be able to:
- Process data from HTML forms.
- Generate dynamic Web pages.
- Capture form data in files.
- Send e-mail from Perl scripts.
- Use the CGI.pm Perl module to make CGI scripting easier.
- Debug Perl CGI scripts.
- Optional/Advanced:
- Use the environment variables set by the Web server.
- Display data in real time.
- Add fields to the server's HTTP response header.
- Lock files to prevent data corruption.
- Grasp the issues of interfacing to legacy systems.
|
Textbook
|
Lincoln Stein, How to Set Up and Maintain a Web Site,
Addison Wesley, 1997. $40.
|
Method
|
A great deal of information is covered in a short amount of time.
The format is highly compressed, with a focus on hands-on exercises
-- the best way to acquire new skills, learning by doing -- that
are carefully designed to rehearse the specific techniques of
interest without extraneous effort.
Source code files are provided to save time typing.
Once you get your solution working, you know you have learned
-- and proven you've learned! -- each of the essential techniques
for programming web-based applications in Perl.
In its method, the course's emphasis is on the practical,
with the majority of the classroom time devoted to hands-on
activity. You set your own pace, with the
instructor acting mainly as a facilitator.
Historical and theoretical material is kept to a minimum.
The main classroom activity is the step-by-step construction
of a web-based
work order and invoicing system for a hypothetical business.
Each student receives a tarfile copy of the sample programs
discussed in the course.
|
Contents
|
- Housekeeping
- review of prerequisites
- course objectives
- related topics
- resources for Perl and CGI programmers (lots!)
- Review of the Basics of Perl
- The Client, the Server, and the Environment
The terminology and mechanisms of the web are
reviewed and presented with emphasis on usefulness
for CGI programming:
- components of the web: clients, servers,
and the HTTP protocol that connects them
- the programming features of the
Common Gateway Interface (CGI), the mechanism
that enables clients to run programs on servers:
- environment variables
- request types
- HTTP headers
- authentication
- Lab: a greeting page with a redirect to another
URL (Uniform Resource Locator) determined according to
the identity of the remote user
- Techniques for Debugging CGI Scripts
In conjunction with a web server,
Perl offers a flexible programming environment
and a variety of techniques are available for troubleshooting:
- redirecting standard error output
- watching log files
- locally simulating the remote client side
- using Perl's command-line switches
- Lab: samples and practice for each method
- Processing Form Data
Web-based forms enable gathering of data from remote users.
These data must then be processed by CGI programs that:
- use the CGI.pm object-oriented Perl module
- lock the data files to prevent multi-user update anomalies
- handle file uploads
- Lab: add a field to a form, validate the datum
entered there, append it to a file
- Dynamic Web Pages
Often, the page displayed by your web browser was not written
by a human but generated by a program.
Its contents can vary according to circumstance, hence
the termdynamic.
Dynamic web page generation techniques discussed in this
chapter include:
- maintaining state information
- CGI.pm HTML shortcuts
- Lab: write a Perl script to dynamically
generate the form from the previous chapter
so that it is one Perl script instead
of a Perl script and an HTML form
- Non-Parsed Headers
Non-Parsed Headers (NPH) are a useful CGI technique for:
- processing data in real time
- Lab: a progress indicator in a frame
- Interfacing to External Applications
Building web-based interfaces to legacy applications and
making use of other computer-based resources is one of the
web's popular uses. The applicable techniques taught here are:
- file locking
- sending mail with attachments
- accessing databases
- Lab:
retrieve service records, e-mail reminder letters
- Conclusion
- review
- summary
- tarfile of course source code
|
Classroom Setup
|
Delivery of this course requires a
classroom equipped with:
- an overhead projector
- a PC or workstation for each student
- a PC or workstation for the instructor
- a projector for the instructor's computer screen
- connection to the internet
- a Perl interpreter and a webserver enabled for CGI
(details) -- can run on
NT or Unix
|
Site
|
The course can be taught in your classroom,
anywhere in the world.
Travel outside the San Francisco Bay Area requires
reimbursement of the instructor's travel expense.
|