| |
| |
Introduction | |
| |
| |
What is a program? | |
| |
| |
Why Perl? | |
| |
| |
What about CGI? | |
| |
| |
Perl and HTML | |
| |
| |
Getting Perl | |
| |
| |
Internet service providers | |
| |
| |
Ask your ISP! | |
| |
| |
About this book | |
| |
| |
What this book is not | |
| |
| |
The Perl and CGI VQS Guide Web Site | |
| |
| |
| |
Perl Building Blocks | |
| |
| |
Perl data | |
| |
| |
Operators and functions | |
| |
| |
Quotation marks | |
| |
| |
| |
Creating Perl CGI Scripts | |
| |
| |
Creating a Perl CGI script | |
| |
| |
Starting a Perl CGI script | |
| |
| |
Writing code in Perl | |
| |
| |
Creating output for a browser | |
| |
| |
Documenting your script | |
| |
| |
Uploading your script to the server | |
| |
| |
Changing permissions | |
| |
| |
Checking the script's syntax | |
| |
| |
Running a Perl CGI script | |
| |
| |
| |
Getting Data from Visitors | |
| |
| |
Labeling incoming data | |
| |
| |
Creating a form | |
| |
| |
Creating text boxes | |
| |
| |
Creating password boxes | |
| |
| |
Creating larger text areas | |
| |
| |
Creating radio buttons | |
| |
| |
Creating checkboxes | |
| |
| |
Creating menus | |
| |
| |
Creating the submit button | |
| |
| |
Resetting the form | |
| |
| |
Using an image to submit data | |
| |
| |
Creating a link to a script | |
| |
| |
Using a link to input data to a script | |
| |
| |
Adding default data to a form | |
| |
| |
| |
Environmental Variables | |
| |
| |
Using environment variables to parse forms | |
| |
| |
Your visitor's browser and platform | |
| |
| |
How did your visitor get to your page? | |
| |
| |
Viewing all the environment variables | |
| |
| |
| |
Getting Data into the Script | |
| |
| |
Inputting data from a form or a link | |
| |
| |
Inputting data from environment variables | |
| |
| |
Inputting scalar data yourself | |
| |
| |
Inputting arrays yourself | |
| |
| |
Inputting hashes yourself | |
| |
| |
| |
Working with Scalars | |
| |
| |
Storing the result of an operation | |
| |
| |
Multiplying, dividing, adding, subtracting | |
| |
| |
Using more than one operator at a time | |
| |
| |
Raising a number to an exponential power | |
| |
| |
Getting the remainder of a division | |
| |
| |
Connecting strings together | |
| |
| |
Repeating a string | |
| |
| |
Operating and assigning in one step | |
| |
| |
Incrementing (or decrementing) a variable | |
| |
| |
| |
Working with Arrays | |
| |
| |
Getting a particular item from an array | |
| |
| |
Splitting a scalar into an array | |
| |
| |
Modifying all the members of an array | |
| |
| |
Finding the length of an array | |
| |
| |
Getting multiple items from an array | |
| |
| |
Adding items to the beginning of an array | |
| |
| |
Adding items to the end of an array | |
| |
| |
Combining two arrays | |
| |
| |
Removing the first item in an array | |
| |
| |
Removing the last item in an array | |
| |
| |
Replacing an item in an array | |
| |
| |
Replacing more than one item in an array | |
| |
| |
Sorting arrays | |
| |
| |
Reversing the order of an array's contents | |
| |
| |
| |
Conditional Statements | |
| |
| |
Comparing numbers | |
| |
| |
Comparing strings | |
| |
| |
Evaluating conditions without comparisons | |
| |
| |
Testing two or more comparisons at a time | |
| |
| |
Creating a basic conditional statement | |
| |
| |
Adding options for false conditions | |
| |
| |
Adding multiple, independent conditions | |
| |
| |
Using unless | |
| |
| |
Repeating a block while a condition is true | |
| |
| |
Repeating a block while a condition is false | |
| |
| |
Executing the block at least once | |
| |
| |
Repeating a block a given number of times | |
| |
| |
Repeating a block for each item in an array | |
| |
| |
Nesting conditional statements | |
| |
| |
| |
Subroutines | |
| |
| |
Creating a simple subroutine | |
| |
| |
Using a simple subroutine | |
| |
| |
Creating a subroutine that takes input | |
| |
| |
Calling a subroutine that takes input | |
| |
| |
Using a subroutine's return value | |
| |
| |
Setting the return value manually | |
| |
| |
Storing subroutines in a separate file | |
| |
| |
Calling subroutines from an external file | |
| |
| |
| |
Working with Hashes | |
| |
| |
Getting a value by using a key | |
| |
| |
Getting several values using keys | |
| |
| |
Getting all of a hash's values | |
| |
| |
Getting all of a hash's keys | |
| |
| |
Getting each key and value in a hash | |
| |
| |
Removing key-value pairs | |
| |
| |
Checking to see if a key exists | |
| |
| |
| |
Analyzing Data | |
| |
| |
Finding something | |
| |
| |
Finding and replacing | |
| |
| |
Seeing and using what was found | |
| |
| |
Splitting a value into pieces | |
| |
| |
Constructing search patterns | |
| |
| |
Tips for constructing search patterns | |
| |
| |
Matching a single character | |
| |
| |
Matching a string of characters | |
| |
| |
Matching a character from a group | |
| |
| |
Matching a character that's not in the group | |
| |
| |
Using class shorthands | |
| |
| |
Limiting the location | |
| |
| |
Choosing how many to match | |
| |
| |
Curbing a quantifier's greediness | |
| |
| |
Matching one element or another | |
| |
| |
More on using what you already matched | |
| |
| |
| |
Remembering What Your Visitors Tell You | |
| |
| |
About hidden fields | |
| |
| |
Adding hidden fields to a form | |
| |
| |
Storing collected data in a hidden field | |
| |
| |
About cookies | |
| |
| |
Looking at your browser's cookies | |
| |
| |
Sending a cookie | |
| |
| |
Setting a cookie's expiration date | |
| |
| |
Limiting a cookie to a domain | |
| |
| |
Limiting a cookie to a part of your server | |
| |
| |
Limiting cookies to secure connections | |
| |
| |
Reading and using a cookie | |
| |
| |
How (and why) your visitors refuse cookies | |
| |
| |
| |
Printing and HTML | |
| |
| |
Formatting output with HTML | |
| |
| |
Printing several lines at a time | |
| |
| |
Simplifying paths to images and links | |
| |
| |
Creating header and footer subroutines | |
| |
| |
Outputting a hash as a table | |
| |
| |
Outputting an array as a list | |
| |
| |
Formatting numbers and strings | |
| |
| |
Formatting numbers as dollars and cents | |
| |
| |
Padding numbers | |
| |
| |
| |
Files and Directories | |
| |
| |
Opening a file | |
| |
| |
Verifying file and directory operations | |
| |
| |
Writing to an external file | |
| |
| |
Getting exclusive access to a file | |
| |
| |
Reading data from an external file | |
| |
| |
Closing a file | |
| |
| |
Renaming a file | |
| |
| |
Removing a file | |
| |
| |
Checking a file's status | |
| |
| |
Accessing a directory | |
| |
| |
Reading the contents of a directory | |
| |
| |
Closing a directory | |
| |
| |
Changing the working directory | |
| |
| |
Creating a directory | |
| |
| |
Changing permissions from within a script | |
| |
| |
Removing a directory | |
| |
| |
Getting ready to e-mail output | |
| |
| |
Sending output via e-mail | |
| |
| |
Eliminating extra returns | |
| |
| |
| |
Debugging | |
| |
| |
Checking the easy stuff | |
| |
| |
Creating an error subroutine | |
| |
| |
Narrowing it down by commenting it out | |
| |
| |
Following a variable's progress | |
| |
| |
| |
Using Other Folks' Scripts | |
| |
| |
Using other folks' scripts | |
| |
| |
Getting other people's scripts | |
| |
| |
Expanding compressed scripts | |
| |
| |
Configuring borrowed scripts | |
| |
| |
Customizing borrowed scripts | |
| |
| |
| |
Parsing Form Input | |
| |
| |
Creating a subroutine | |
| |
| |
Determining which method was used | |
| |
| |
Getting name-value pairs from GET | |
| |
| |
Getting name-value pairs from POST | |
| |
| |
Storing name-value pairs in a hash | |
| |
| |
Using the parsed data | |
| |
| |
| |
Permissions | |
| |
| |
Who's the owner? | |
| |
| |
Default permissions | |
| |
| |
Figuring out the new permissions code | |
| |
| |
| |
Security | |
| |
| |
Monitoring visitor input | |
| |
| |
Watching what is sent to the server | |
| |
| |
Avoiding tainted data | |
| |
| |
| |
Unix Essentials | |
| |
| |
Telnetting to your Unix server | |
| |
| |
Executing commands in Unix | |
| |
| |
Dealing with paths in Unix | |
| |
| |
Changing the working directory | |
| |
| |
Finding out where you are | |
| |
| |
Listing directory contents | |
| |
| |
Eliminating files | |
| |
| |
Creating and eliminating directories | |
| |
| |
Decompressing tar and zipped files | |
| |
| |
Getting help with Unix | |
| |
| |
| |
Perl and CGI Resources | |
| |
| |
Text editors | |
| |
| |
Telnet programs | |
| |
| |
Other folks' scripts | |
| |
| |
Learning more | |
| |
| |
Index | |