- Shopping Bag ( 0 items )
Perl is one of the most popular scripting languages for adding powerful interactive features to Web pages. Perl lets you place forms on your site that collect and process user input such as comments and product orders; enables visitors to search for information; and can integrate a database into your site, among its many other capabilities. Perl and CGI for the World Wide Web, 2nd Edition: Visual QuickStart Guide fully revised and updated since its original 1998 release, gets users to the core of CGI scripting with Perl. Even first-time programmers will be able to create useful, workable scripts from scratch, or adapt and customize existing scripts to their own needs. Hundreds of screen shots and clear, easy-to-understand directions make this the perfect Perl book for beginners, as well as a handy reference for those with previous programming experience.
Perl and CGI for the World Wide Web: Visual QuickStart Guide gets you to the heart of Perl scripting with CGI...
Maybe programmers like this mystique... certainly they don't seem to make it easy to break into the art of programming. Most books that you read about programming start off somewhere in the middle, assuming you've already done some programming somewhere, and that you're just learning a new language, with the basic concepts already under your belt.
This book starts at the very beginning. Even if you've never, ever programmed before, you'll be able to understand this book. At the same time, I won't bore you to tears with a lot of theory or lengthy explanations. And I won't treat you like an idiot. We'll get started right away, but we'll start at the beginning. You don't have to have any previous knowledge of Unix commands, you don't have to already know what a variable is, or what arrays are, or any of that incomprehensible programspeak: I'll teach you as we go along. Let's start!
Unfortunately, programs aren't written in English (or any other spoken language). Instead, they're written in languages that are easy for computers to understand. And since the computers are the ones that have to do most of the work, I suppose that makes sense. Some common programming languages are C, C++, Pascal, and, well, Perl.
Like spoken languages, computer languages have their own grammar, syntax, and even their own punctuation. Thankfully, computer languages are generally a lot easier to learn than, say, French or Japanese. Computer languages have few or no exceptions (no, "i before a except after c"), and the rules are generally straightforward and easy to follow. And, you don't have to worry about pronunciation!
In fact, nowadays, people use Perl to do a wide variety of things. But one of its most popular uses is to make Web pages interactive. There are Perl scripts for processing forms, creating guestbooks, creating Webbased bulletin boards, counting the number of times a Web page is visited, and much more.
Perl is particularly suited to Web-related tasks for three reasons. First, it is a powerful textmanipulation tool. You can take a long stream of characters (say, the information entered into a Web form) and quickly separate it into fields and data-that is, information that can be used, compiled, and stored. Second, Perl is easily moved (ported) from one platform to another. A script written on a Windows system can be easily copied to a Unix machine or Macintosh with few or no changes. Next, Perl has a reputation as a cool language-really! Perl programmers love to brag about how they can do anything with Perl, on one line, in several different ways. Finally, Perl is fun!
So, some Pert scripts are CGI scripts (the ones that follow the CGI protocol) and some are not. And some so-called CGI scripts are Pert scripts (the ones that are written in Pert), but some are not (they are also commonly found written in C, tcl, Visual Basic, and AppleScript).
In this book, you'll learn about creating Pert CGI scripts-specifically for getting, processing, and returning information through your Web pages. For information on learning more about non-Web related applications for Pert scripts, consult Appendix E, Perl and CGI Resources.
It is extremely important that you take all of the necessary precautions (as discussed throughout this book) so that you don't leave your server vulnerable. I discuss security in more detail in Chapter 18, Security, starting on page 237....
What is a Program? Why Perl? What about CGI? Security Issues. Perl and HTML. About This Book. What This Book is Not. What's New. The Perl and CGI VQS Guide Web Site.
2. Perl Building Blocks.
Perl Data. Operators and Functions. Quotation Marks. Quoting without Quotes. Statements, Blocks, and Scope. Declaring Private Variables. The Shebang Line. Creating a Perl CGI Script. Creating Output for a Browser. Documenting Your Script. Checking the Script's Syntax.
3. About Servers, Perl, and CGI.pm.
What is a Server? The Importance of Directories. Ask Your Web Host! Getting a Perl Interpreter. Getting CGI.pm.
4. Running Perl CGI on a Unix Server.
Which Perl are They Running? What About CGI.pm? Installing Scripts on Unix Servers. Uploading Your Script. Changing Permissions. Testing Your Unix Server.
5. Testing Scripts Locally on Windows.
Installing the Xitami or Sambar Server. Installing Personal Web Server. Installing IIS on Windows 2000. Displaying File Extensions. Testing Your Server (Part I). Installing the Perl Interpreter. Installing CGI.pm. Installing Scripts on Windows Servers. Testing Your Server (Part II).
6. Testing Scripts Locally on the Mac.
Installing Personal Web Sharing. The Root Web Directory. Carefully Sharing the Root Web Directory. Starting the Web Sharing Server. Testing the Server (Part I). Installing MacPerl. Installing CGI.pm. Installing Scripts on Mac Servers. Testing Your Server (Part II).
7. 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.
8. Environment Variables.
Your Visitor's Browser and Platform. Viewing Available Environment Variables. Storing Data from Environment Variables.
9. Getting Data into the Script.
Getting Single-Valued Form Data. Getting Multiple-Valued From Data. Getting All the Form Element's Names. Getting All the Names and Values.
10. Simple Operations with Scalars.
Assigning a Value to a Scalar Variable. Multiplying, Dividing, Adding, Subtracting. Using More Than One Operator. Raising a Number to an Exponential Power. Using Mathematical Functions. Getting the Remainder of a Division. Connecting Strings Together. Repeating a String. Operating and Assigning in One Step. Incrementing (or Decrementing) a Variable.
11. Conditionals and Loops.
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 for Each Item in an Array. Loading the Default Variable. 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. Nesting Conditional Statements. Skipping a Loop Iteration. Jumping Out of a Loop Altogether.
12. Working with Arrays.
Assigning a List to an Array Variable. Referring to a Particular Item in an Array. Referring to Multiple Items in an Array. Adding or Replacing an Item in an Array. Adding to the End or Beginning of an Array. Removing the Last Item from an Array. Removing the First Item from an Array. Replacing More Than One Item in an Array. Finding the Length of an Array. Modifying All the Members of an Array. Sorting Arrays. Reversing the Order of an Array's Contents.
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 an External File. Calling Subroutines from an External File.
14. Working with Hashes.
Assigning a List to a Hash. Getting a Value by Using a Key. Adding or Replacing a Key-Value Pair. Getting Several Values Using Keys. Getting All of a Hash's Keys. Getting All of a Hash's Values. Getting Each Key and Value in a Hash. Getting the Pairs in a Specified Order. Removing Key-Value Pairs. Checking to See If a Key Exists.
15. 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 Locations. Choosing How Many to Match. Curbing a Quantifier's Greediness. Matching One Element or Another. More on Using What You Already Matched.
16. Remembering what Visitors Tell You.
17. Formatting, Printing, and HTML.
Formatting Output with Perl. Creating a Format Pattern for Integers. Creating a Format Pattern for Non-Integers. Creating a Pattern for Strings. Changing the Case. Changing Characters. Finding the Length of a String. Finding Where Something is in a String. Extracting One String from Another. Cleaning up the End of a String. Formatting Output with HTML. Printing Several Lines at a Time. Simplifying Paths to Images and Links. Outputting Data in a Table.
Reading the Security FAQs. The Problem with Visitor Input. Protecting Calls to the Systems. Limiting Access to Files. Using CGI.pm to Limit Incoming Data. Keeping Information to Yourself. Avoiding Tainted Data. Cleaning and Using Outside Data.
19. 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. Opening 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.
20. Uploading Files.
Creating a Form for Uploading Files. Getting the Name of the Uploaded File. Finding Out a File's MIME Type. Specifying Where the File Should be Saved. Reading in and Limiting the Uploaded Files.
Appendix A: Debugging.
Checking the Easy Stuff. Creating an Error Subroutine. Using Perl's Error Reporting. Viewing the System Error Log. Isolating the Problem. Following a Variable's Progress.
Appendix B: Using Other Folks' Scripts.
Using Other Folks' Scripts. Getting Other People's Scripts. Expanding Compressed Scripts. Configuring Borrowed Scripts. Customizing Borrowed Scripts.
Appendix C: Permissions on Unix.
Figuring Out the Permissions Code. Default Permissions. Who's the Owner?
Appendix D: 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.
Appendix E: Perl and CGI Resources.
Text Editors. Telnet Programs. Other Folks' Scripts. Learning More.
Posted October 29, 2002
I bought this book with zero knowledge of Perl. I found the book priceless. It helped me crank out dozens of web server cgi scripts in a matter of days. My only complaint is that I wish it was longer and more thorough. Or I wish the author had a complementary book to follow in the same "easy to follow" format. This is a must have book for non-Unix Perl newbies especially.
1 out of 1 people found this review helpful.Was this review helpful? Yes NoThank you for your feedback. Report this reviewThank you, this review has been flagged.
Posted September 27, 2001
This is a great book for someone who's really interested in learning Perl for writing CGI scripts, and who already has a decent basis in programming. When I purchased this book I already had a very basic understanding of some Perl concepts, and I just used this as a resource... it's fantastic!!!Was this review helpful? Yes NoThank you for your feedback. Report this reviewThank you, this review has been flagged.
Posted August 13, 2001
I am a senior web-programmer for a Silicon Valley based internet company. I have read almost every book on PERL, PYTHON, CGI, and UNIX... and this author, this publisher, puts all the technical jargon, into readable lessons for today's web-programmer.Was this review helpful? Yes NoThank you for your feedback. Report this reviewThank you, this review has been flagged.