Cover image for PERL and CGI for the World Wide Web
PERL and CGI for the World Wide Web
Castro, Elizabeth.
Personal Author:
Publication Information:
Berkeley, CA : Peachpit Press, [1999]

Physical Description:
272 pages : illustrations ; 23 cm.
General Note:
Includes index.
Format :


Call Number
Material Type
Home Location
Item Holds
QA76.625 .C37 1999 Adult Non-Fiction Central Closed Stacks

On Order



Perl and CGI for the World Wide Web: Visual QuickStart Guide gets you to the heart of Perl scripting with CGI. Even first-time programmers will be able to create interactive Web pages and, more importantly, use their new-found familiarity with Perl to understand and customize the multitude of scripts that already exist on the Web. Following on the huge success of Liz Castros top-selling HTML 4: Visual QuickStart Guide - the book on HTML - Elizabeth Castros Perl and CGI for the World Wide Web: Visual QuickStart Guide is sure to become the choice for learning Perl and CGI

Author Notes

Elizabeth Castro has written three bestselling editions of HTML for the World Wide Web: Visual QuickStart Guide. She also wrote the Macintosh and Windows versions of the Netscape Communicator 4: Visual QuickStart Guide. She was the technical editor for Peachpit's The Macintosh Bible, Fifth Edition, and she founded Pagina Uno, a publishing house based in Barcelona, Spain.

Table of Contents

Introductionp. 13
What is a program?p. 14
Why Perl?p. 15
What about CGI?p. 16
Perl and HTMLp. 17
Getting Perlp. 18
Internet service providersp. 19
Ask your ISP!p. 19
About this bookp. 20
What this book is notp. 21
The Perl and CGI VQS Guide Web Sitep. 22
Chapter 1 Perl Building Blocksp. 23
Perl datap. 23
Operators and functionsp. 26
Quotation marksp. 28
Chapter 2 Creating Perl CGI Scriptsp. 29
Creating a Perl CGI scriptp. 30
Starting a Perl CGI scriptp. 32
Writing code in Perlp. 33
Creating output for a browserp. 34
Documenting your scriptp. 35
Uploading your script to the serverp. 36
Changing permissionsp. 39
Checking the script's syntaxp. 40
Running a Perl CGI scriptp. 41
Chapter 3 Getting Data from Visitorsp. 43
Labeling incoming datap. 44
Creating a formp. 46
Creating text boxesp. 47
Creating password boxesp. 48
Creating larger text areasp. 49
Creating radio buttonsp. 50
Creating checkboxesp. 51
Creating menusp. 52
Creating the submit buttonp. 53
Resetting the formp. 54
Using an image to submit datap. 55
Creating a link to a scriptp. 56
Using a link to input data to a scriptp. 57
Adding default data to a formp. 58
Chapter 4 Environmental Variablesp. 59
Using environment variables to parse formsp. 60
Your visitor's browser and platformp. 62
How did your visitor get to your page?p. 63
Viewing all the environment variablesp. 64
Chapter 5 Getting Data into the Scriptp. 65
Inputting data from a form or a linkp. 66
Inputting data from environment variablesp. 68
Inputting scalar data yourselfp. 69
Inputting arrays yourselfp. 70
Inputting hashes yourselfp. 71
Chapter 6 Working with Scalarsp. 73
Storing the result of an operationp. 74
Multiplying, dividing, adding, subtractingp. 75
Using more than one operator at a timep. 76
Raising a number to an exponential powerp. 77
Getting the remainder of a divisionp. 78
Connecting strings togetherp. 79
Repeating a stringp. 80
Operating and assigning in one stepp. 81
Incrementing (or decrementing) a variablep. 82
Chapter 7 Working with Arraysp. 83
Getting a particular item from an arrayp. 84
Splitting a scalar into an arrayp. 86
Modifying all the members of an arrayp. 87
Finding the length of an arrayp. 88
Getting multiple items from an arrayp. 89
Adding items to the beginning of an arrayp. 90
Adding items to the end of an arrayp. 91
Combining two arraysp. 92
Removing the first item in an arrayp. 93
Removing the last item in an arrayp. 94
Replacing an item in an arrayp. 95
Replacing more than one item in an arrayp. 96
Sorting arraysp. 98
Reversing the order of an array's contentsp. 99
Chapter 8 Conditional Statementsp. 101
Comparing numbersp. 102
Comparing stringsp. 103
Evaluating conditions without comparisonsp. 104
Testing two or more comparisons at a timep. 105
Creating a basic conditional statementp. 106
Adding options for false conditionsp. 107
Adding multiple, independent conditionsp. 108
Using unlessp. 109
Repeating a block while a condition is truep. 110
Repeating a block while a condition is falsep. 111
Executing the block at least oncep. 112
Repeating a block a given number of timesp. 113
Repeating a block for each item in an arrayp. 114
Nesting conditional statementsp. 115
Chapter 9 Subroutinesp. 117
Creating a simple subroutinep. 118
Using a simple subroutinep. 119
Creating a subroutine that takes inputp. 120
Calling a subroutine that takes inputp. 121
Using a subroutine's return valuep. 122
Setting the return value manuallyp. 123
Storing subroutines in a separate filep. 124
Calling subroutines from an external filep. 125
Chapter 10 Working with Hashesp. 127
Getting a value by using a keyp. 128
Getting several values using keysp. 129
Getting all of a hash's valuesp. 130
Getting all of a hash's keysp. 131
Getting each key and value in a hashp. 132
Removing key-value pairsp. 134
Checking to see if a key existsp. 135
Chapter 11 Analyzing Datap. 137
Finding somethingp. 138
Finding and replacingp. 139
Seeing and using what was foundp. 140
Splitting a value into piecesp. 141
Constructing search patternsp. 142
Tips for constructing search patternsp. 143
Matching a single characterp. 144
Matching a string of charactersp. 145
Matching a character from a groupp. 146
Matching a character that's not in the groupp. 147
Using class shorthandsp. 148
Limiting the locationp. 149
Choosing how many to matchp. 151
Curbing a quantifier's greedinessp. 156
Matching one element or anotherp. 157
More on using what you already matchedp. 158
Chapter 12 Remembering What Your Visitors Tell Youp. 161
About hidden fieldsp. 162
Adding hidden fields to a formp. 163
Storing collected data in a hidden fieldp. 164
About cookiesp. 166
Looking at your browser's cookiesp. 167
Sending a cookiep. 168
Setting a cookie's expiration datep. 170
Limiting a cookie to a domainp. 171
Limiting a cookie to a part of your serverp. 172
Limiting cookies to secure connectionsp. 173
Reading and using a cookiep. 174
How (and why) your visitors refuse cookiesp. 176
Chapter 13 Printing and HTMLp. 177
Formatting output with HTMLp. 178
Printing several lines at a timep. 180
Simplifying paths to images and linksp. 181
Creating header and footer subroutinesp. 182
Outputting a hash as a tablep. 184
Outputting an array as a listp. 185
Formatting numbers and stringsp. 186
Formatting numbers as dollars and centsp. 187
Padding numbersp. 188
Chapter 14 Files and Directoriesp. 189
Opening a filep. 190
Verifying file and directory operationsp. 192
Writing to an external filep. 193
Getting exclusive access to a filep. 194
Reading data from an external filep. 195
Closing a filep. 196
Renaming a filep. 197
Removing a filep. 198
Checking a file's statusp. 199
Accessing a directoryp. 200
Reading the contents of a directoryp. 201
Closing a directoryp. 202
Changing the working directoryp. 203
Creating a directoryp. 204
Changing permissions from within a scriptp. 205
Removing a directoryp. 206
Getting ready to e-mail outputp. 207
Sending output via e-mailp. 208
Eliminating extra returnsp. 210
Chapter 15 Debuggingp. 211
Checking the easy stuffp. 212
Creating an error subroutinep. 214
Narrowing it down by commenting it outp. 215
Following a variable's progressp. 216
Chapter 16 Using Other Folks' Scriptsp. 217
Using other folks' scriptsp. 218
Getting other people's scriptsp. 219
Expanding compressed scriptsp. 220
Configuring borrowed scriptsp. 221
Customizing borrowed scriptsp. 222
Appendix A Parsing Form Inputp. 223
Creating a subroutinep. 223
Determining which method was usedp. 224
Getting name-value pairs from GETp. 226
Getting name-value pairs from POSTp. 227
Storing name-value pairs in a hashp. 228
Using the parsed datap. 230
Appendix B Permissionsp. 231
Who's the owner?p. 232
Default permissionsp. 233
Figuring out the new permissions codep. 234
Appendix C Securityp. 235
Monitoring visitor inputp. 236
Watching what is sent to the serverp. 237
Avoiding tainted datap. 238
Appendix D Unix Essentialsp. 239
Telnetting to your Unix serverp. 240
Executing commands in Unixp. 242
Dealing with paths in Unixp. 243
Changing the working directoryp. 246
Finding out where you arep. 247
Listing directory contentsp. 248
Eliminating filesp. 249
Creating and eliminating directoriesp. 250
Decompressing tar and zipped filesp. 251
Getting help with Unixp. 252
Appendix E Perl and CGI Resourcesp. 253
Text editorsp. 254
Telnet programsp. 255
Other folks' scriptsp. 256
Learning morep. 257
Indexp. 259