| |
| |
About the Author | |
| |
| |
Introduction | |
| |
| |
Getting Started | |
| |
| |
Overview of CGI | |
| |
| |
Chapter Objectives | |
| |
| |
What Is CGI? | |
| |
| |
Why Is CGI Useful? | |
| |
| |
Client/Server Applications | |
| |
| |
The HTTP Protocol | |
| |
| |
The CGI Process | |
| |
| |
Is CGI Dead? | |
| |
| |
Key Points | |
| |
| |
Summary | |
| |
| |
The CGI Framework | |
| |
| |
Chapter Objectives | |
| |
| |
Pros and Cons of Hosting Your Own Web Server | |
| |
| |
Hardware Concerns | |
| |
| |
Choosing a Platform | |
| |
| |
Choosing Web Server Software | |
| |
| |
What to Ask Your Web Hosting Company | |
| |
| |
Key Points | |
| |
| |
Summary | |
| |
| |
Installing a CGI Script | |
| |
| |
Chapter Objectives | |
| |
| |
Selecting a Text Editor | |
| |
| |
Uploading Your Files | |
| |
| |
Getting around on Your Web Server | |
| |
| |
Installing Your First CGI Script | |
| |
| |
Key Points | |
| |
| |
Summary | |
| |
| |
Perl Building Blocks | |
| |
| |
Introduction to Perl | |
| |
| |
Chapter Objectives | |
| |
| |
Origin of Perl | |
| |
| |
About the Language | |
| |
| |
Why Use Perl? | |
| |
| |
Perl Competitors | |
| |
| |
Writing Perl | |
| |
| |
Designing Your First Perl Script for the Internet | |
| |
| |
Key Points | |
| |
| |
Exercises | |
| |
| |
Summary | |
| |
| |
Using the Print Statement | |
| |
| |
Chapter Objectives | |
| |
| |
Using the Print Function | |
| |
| |
Using the Here Document | |
| |
| |
Using q and qq | |
| |
| |
Key Points | |
| |
| |
Exercises | |
| |
| |
Summary | |
| |
| |
Using Variables | |
| |
| |
Chapter Objectives | |
| |
| |
Scalar Variables | |
| |
| |
List Arrays | |
| |
| |
Key Points | |
| |
| |
Exercises | |
| |
| |
Summary | |
| |
| |
Statements and Conditionals | |
| |
| |
Chapter Objectives | |
| |
| |
Conditional Control Statements | |
| |
| |
Looping Control Statements | |
| |
| |
Key Points | |
| |
| |
Exercise | |
| |
| |
Summary | |
| |
| |
Using Subroutines | |
| |
| |
Chapter Objectives | |
| |
| |
Subroutine Basics | |
| |
| |
Return Values | |
| |
| |
Key Points | |
| |
| |
Exercises | |
| |
| |
Summary | |
| |
| |
Pattern Matching | |
| |
| |
Chapter Objectives | |
| |
| |
The Match Operator | |
| |
| |
Grouping and Memory | |
| |
| |
Substitutions | |
| |
| |
Key Points | |
| |
| |
Exercises | |
| |
| |
Summary | |
| |
| |
File Input and Output | |
| |
| |
Chapter Objectives | |
| |
| |
Creating a New File | |
| |
| |
File Tests | |
| |
| |
File Functions | |
| |
| |
Opening and Closing Files | |
| |
| |
Reading a File | |
| |
| |
Writing to a File | |
| |
| |
Appending to a File | |
| |
| |
File Permissions | |
| |
| |
File Locking | |
| |
| |
Key Points | |
| |
| |
Exercises | |
| |
| |
Summary | |
| |
| |
Working with HTML Forms | |
| |
| |
Chapter Objectives | |
| |
| |
Post | |
| |
| |
Get | |
| |
| |
Using cgi-lib.pl | |
| |
| |
Using CGI.pm | |
| |
| |
Page Redirection | |
| |
| |
Using Hidden Fields | |
| |
| |
Key Points | |
| |
| |
Exercises | |
| |
| |
Summary | |
| |
| |
Using Databases | |
| |
| |
Chapter Objectives | |
| |
| |
How Relational Databases Work | |
| |
| |
SQL | |
| |
| |
Using the DBI Module | |
| |
| |
Communicating with the Database | |
| |
| |
Key Points | |
| |
| |
Exercises | |
| |
| |
Summary | |
| |
| |
Interacting with Your Operating System | |
| |
| |
Chapter Objectives | |
| |
| |
Built-in Functions | |
| |
| |
System Calls | |
| |
| |
Sending Email | |
| |
| |
Getting the Time and Date | |
| |
| |
Key Points | |
| |
| |
Exercises | |
| |
| |
Summary | |
| |
| |
Advanced Perl Techniques | |
| |
| |
Error Handling | |
| |
| |
Chapter Objectives | |
| |
| |
Checking for Possible Errors | |
| |
| |
Handling Errors | |
| |
| |
Key Points | |
| |
| |
Exercises | |
| |
| |
Summary | |
| |
| |
Debugging Perl Scripts | |
| |
| |
Chapter Objectives | |
| |
| |
Server Errors | |
| |
| |
Syntax Errors | |
| |
| |
General Tips | |
| |
| |
Key Points | |
| |
| |
Summary | |
| |
| |
Securing Your Perl Script | |
| |
| |
Chapter Objectives | |
| |
| |
Origins of Security Breeches | |
| |
| |
Solutions | |
| |
| |
Wrappers | |
| |
| |
Key Points | |
| |
| |
Exercises | |
| |
| |
Summary | |
| |
| |
Putting It All Together | |
| |
| |
Planning Your Script | |
| |
| |
Chapter Objectives | |
| |
| |
Identify the Functionality | |
| |
| |
Maintainability | |
| |
| |
Key Points | |
| |
| |
Exercises | |
| |
| |
Summary | |
| |
| |
Email Response Form | |
| |
| |
Chapter Objectives | |
| |
| |
Address the Functionality | |
| |
| |
The Script | |
| |
| |
Uploading the Script | |
| |
| |
Troubleshooting the Script | |
| |
| |
Variations | |
| |
| |
Key Points | |
| |
| |
Exercises | |
| |
| |
Summary | |
| |
| |
Guestbook | |
| |
| |
Chapter Objectives | |
| |
| |
Address the Functionality | |
| |
| |
The Script | |
| |
| |
Advanced Technique | |
| |
| |
Uploading the Files | |
| |
| |
Troubleshooting the Files | |
| |
| |
Variations | |
| |
| |
Key Points | |
| |
| |
Exercises | |
| |
| |
Summary | |
| |
| |
Flat-File Databases | |
| |
| |
Chapter Objectives | |
| |
| |
Address the Functionality | |
| |
| |
Adding Entries to a Flat-File Database | |
| |
| |
The Script | |
| |
| |
Searching the Database | |
| |
| |
Deleting Entries from the Database | |
| |
| |
Troubleshooting the Files | |
| |
| |
Variations | |
| |
| |
Key Points | |
| |
| |
Exercises | |
| |
| |
Summary | |
| |
| |
Request and Response Headers | |
| |
| |
Sample Requests | |
| |
| |
General Headers | |
| |
| |
Date | |
| |
| |
Mime-Version | |
| |
| |
Pragma | |
| |
| |
Request Headers | |
| |
| |
Accept | |
| |
| |
Authorization | |
| |
| |
From | |
| |
| |
If-modified-since | |
| |
| |
Referer | |
| |
| |
User-agent | |
| |
| |
Response Headers | |
| |
| |
Retry-After | |
| |
| |
Server | |
| |
| |
Set-Cookie | |
| |
| |
Entity Headers | |
| |
| |
Allow | |
| |
| |
Expires | |
| |
| |
Content-encoding | |
| |
| |
Content-length | |
| |
| |
Content-type | |
| |
| |
Last-modified | |
| |
| |
Location | |
| |
| |
Server Status Code | |
| |
| |
Informational 1XX | |
| |
| |
Success 2XX | |
| |
| |
Redirection 3XX | |
| |
| |
Client Request Incomplete 4XX | |
| |
| |
Server Error 5XX | |
| |
| |
Basic Unix Commands | |
| |
| |
pwd | |
| |
| |
ls | |
| |
| |
mkdir | |
| |
| |
rmdir | |
| |
| |
cp | |
| |
| |
mv | |
| |
| |
rm | |
| |
| |
grep | |
| |
| |
Environment Variables | |
| |
| |
Auth_Type | |
| |
| |
Content_Length | |
| |
| |
Content_Type | |
| |
| |
Gateway_Interface | |
| |
| |
Http_Accept | |
| |
| |
Http_User_Agent | |
| |
| |
Path_Info | |
| |
| |
Path_Translated | |
| |
| |
Query_String | |
| |
| |
Remote_Addr | |
| |
| |
Remote_Host | |
| |
| |
Remote_Ident | |
| |
| |
Request_Method | |
| |
| |
Remote_User | |
| |
| |
Script_Name | |
| |
| |
Server_Name | |
| |
| |
Server_Port | |
| |
| |
Server_Protocol | |
| |
| |
Server_Software | |
| |
| |
Perl Special Variables | |
| |
| |
Special Variables Used with Files | |
| |
| |
$. | |
| |
| |
$/ | |
| |
| |
$### | |
| |
| |
$^F | |
| |
| |
$ARGV | |
| |
| |
Special Variables Used with Patterns | |
| |
| |
$and | |
| |
| |
$' | |
| |
| |
$' | |
| |
| |
$+ | |
| |
| |
$* | |
| |
| |
Special Variables Used with Arrays | |
| |
| |
$" | |
| |
| |
$[ | |
| |
| |
$; | |
| |
| |
Special Variables Used with Printing | |
| |
| |
$, | |
| |
| |
$\ | |
| |
| |
$ | |
| |
| |
Special Variables Used with Processes | |
| |
| |
$$ | |
| |
| |
$? | |
| |
| |
$0 | |
| |
| |
$] | |
| |
| |
$! | |
| |
| |
$@ | |
| |
| |
$^T | |
| |
| |
$^X | |
| |
| |
%ENV | |
| |
| |
%SIG | |
| |
| |
$[ | |
| |
| |
$] | |
| |
| |
$) | |
| |
| |
Miscellaneous Special Variables | |
| |
| |
$_ | |
| |
| |
$^D | |
| |
| |
@ARGV | |
| |
| |
@INC | |
| |
| |
%INC | |
| |
| |
Perl Built-in Functions | |
| |
| |
chdir | |
| |
| |
chmod | |
| |
| |
chop | |
| |
| |
chown | |
| |
| |
close | |
| |
| |
defined | |
| |
| |
delete | |
| |
| |
die | |
| |
| |
each | |
| |
| |
eval | |
| |
| |
exec | |
| |
| |
exists | |
| |
| |
exit | |
| |
| |
getc | |
| |
| |
grep | |
| |
| |
index | |
| |
| |
join | |
| |
| |
keys | |
| |
| |
last | |
| |
| |
length | |
| |
| |
localtime | |
| |
| |
mkdir | |
| |
| |
next | |
| |
| |
open | |
| |
| |
pop | |
| |
| |
print | |
| |
| |
push | |
| |
| |
read | |
| |
| |
rename | |
| |
| |
return | |
| |
| |
reverse | |
| |
| |
rmdir | |
| |
| |
s/reg exp/replacement text/ | |
| |
| |
select | |
| |
| |
shift | |
| |
| |
sort | |
| |
| |
splice | |
| |
| |
split | |
| |
| |
stat | |
| |
| |
substr | |
| |
| |
system | |
| |
| |
time | |
| |
| |
undef | |
| |
| |
unlink | |
| |
| |
values | |
| |
| |
SQL Commands | |
| |
| |
Data Definition Language (DDL) Statements | |
| |
| |
Data Manipulation Language (DML) Statements | |
| |
| |
SQL Conditionals | |
| |
| |
Relational Operators | |
| |
| |
Logical Operators | |
| |
| |
Compound Conditionals | |
| |
| |
Perl Quick Reference | |
| |
| |
Scalars | |
| |
| |
Uninterpreted Strings | |
| |
| |
Interpreted Strings | |
| |
| |
Arrays | |
| |
| |
Manipulating Arrays | |
| |
| |
Associative Arrays | |
| |
| |
Manipulating Associative Arrays | |
| |
| |
Control Statements | |
| |
| |
File Input/Output | |
| |
| |
Printing to a File | |
| |
| |
Reading from a File | |
| |
| |
Regular Expressions | |
| |
| |
Example Patterns | |
| |
| |
Modifiers | |
| |
| |
String Matching | |
| |
| |
Special Variables | |
| |
| |
Substitutions and Translations | |
| |
| |
split() and join() | |
| |
| |
$_ | |
| |
| |
Subroutines | |
| |
| |
Syntax | |
| |
| |
Examples | |
| |
| |
Returning Values | |
| |
| |
Index | |