OFFICIAL GUIDE TO PROGRAMMING
WITH CGI.PM
Example Scripts from the Book
Here is the source code for all the examples from the book. Each example
is listed by chapter, listing number, and page number. You'll find two links
for each example. The top link will run the script so that you can try it
out for yourself. The bottom link will take you to the source code for the
script. You may read through it online or download it to your own machine.
There are several ways to download
a script's source code. One way is to choose File->Save As...
from the browser's menu when the script appears on the screen. Another
way is to simply cut and paste from the browser window to your favorite
word processor. Some browsers also offer you the ability to save the contents
of a link by right-clicking, control-clicking, or by command-clicking,
depending on the browser software and the type of computer you are using.
There are no restrictions on
your use of this source code. Feel free to redistribute it, modify it
for your own purposes, or incorporate it into your own projects. Have
fun!
Chapter 2: CGI.pm Basics
- plaintext.pl:
A dynamic text-only page (page 22).
- Run
the script
- See
its source code
- plaintext2.pl:
Multiple formatted lines (page 24).
- Run
the script
- See
its source code
- plaintext3.pl:
As above, but with simpler code (page 25).
- Run
the script
- See
its source code
- plaintext4.pl:
Star out all 4-letter words from a file (page 26).
- Run
the script
- See
its source code
- See
the unmodified file
- time1.pl: Print
the current local time (page 27).
- Run
the script
- See
its source code
- time2.pl: A different
way to print the current local time (page 30).
- Run
the script
- See
its source code
- time3.pl: As before,
but with an inline image (page 32).
- Run
the script
- See
its source code
- vegetables1.pl:
Nested lists (page 34).
- Run
the script
- See
its source code
- vegetables2.pl:
Same thing, more concisely (page 37).
- Run
the script
- See
its source code
- vegetables3.pl:
An HTML 3 table(page 39).
- Run
the script
- See
its source code
- htmlize.pl: Convert
text into HTML(page 41).
- Run
the script
- See
its source code
- See
the unmodified table
- time4.pl: An interactive
clock (listing 2.1, page 48).
- Run
the script
- See
its source code
- advice.pl: Take
action based on button presses (listing 2.2, page 67).
- Run
the script
- See
its source code
- loan.pl: Multi-page
questionnaire (listing 2.3, page 70).
- Run
the script
- See
its source code
- guestbook.pl:
A guestbook (listing 2.4, page 79).
- Run
the script
- See
its source code
- See
the raw guestbook file
- redirect.pl: Redirect
browser elsewhere (page 91).
- This script will redirect
you to the book's home page
- Run
the script
- See
its source code
- random_pict1.pl:
Select a picture randomly (listing 2.4, page 92)
- Run
the script
- See
its source code
- See
the directory of pictures
- random_pict2.cgi:
A more portable version of above (listing 2.5, page 94)
- Run
the script
- See
its source code
- tm.pl: Add ®
symbol to trademarks (listing 2.6, page 96)
- Run
the script
- See its
source code
- See
the unmodified target file
- confidential.pl:
Implement a new <CONFIDENTIAL> HTML tag (listing 2.7, page 98)
- Run
the script
- See
its source code
- See
the unmodified target file
- See
the unmodified target file's source
Chapter 3: Advanced Tricks
- carpout.pl: Echo
runtime errors to the browser (page 107).
- When you run this, the
script will display an error message.
- Run
the script
- See
its source code
- quadraphobia.pl:
A clickable image map (page 118XX).
- Run
the script
- See
its source code
- graffiti.pl: Saving
session state to a file (listing 3.1, page 122).
- Run
the script
- See
its source code
- customizable.pl:
A customizable page (page 130.
- Run
the script
- See
its source code
- graffiti2.pl:
A cleaner way of saving session state to a file (listing 3.2, page 132).
- Run
the script
- See
its source code
- cookie.pl: Save
user preferences in a cookie (listing 3.3, page 144).
- Run
the script
- See
its source code
- upload.pl: Upload
a file and calculate its length (listing 3.4, page 152).
- Run
the script
- See
its source code
- gate.pl: Refuse
admission between 2-3 o'clock on Sundays (listing 3.5, page 159).
- Run
the script
- See
its source code
- frames.pl: Create
a document that uses frames to pop up a new window (listing 3.6, page
164).
- Run
the script
- See
its source code
- side_by_side.pl:
Create side-by-side frames (listing 3.7, page 166).
- Run
the script
- See
its source code
- javascript.pl:
Validate a form with JavaScript (listing 3.8, page 177).
- Run
the script
- See
its source code
- nph-quote.pl:
Simulate a stock ticker (listing 3.9, page 184).
- Run
the script
- See
its source code
- nph-push.pl: A
dynamic page using server push (page 188).
- Run
the script
- See
its source code
|
|
ISBN 0-471-24744-8
310 pages
April, 1998
Wiley
Computer Publishing
Timely. Practical. Reliable.
|