Click Here!
home account info subscribe login search My ITKnowledge FAQ/help site map contact us


 
Brief Full
 Advanced
      Search
 Search Tips
To access the contents, click the chapter and section titles.

Perl CGl Programming: No experience required.
(Publisher: Sybex, Inc.)
Author(s): Erik Strom
ISBN: 0782121578
Publication Date: 11/01/97

Bookmark It

Search this book:
 
Table of Contents


Introduction

There is no question that the World Wide Web is booming these days. Cheap Internet access, powerful computers, fast modems, and software that is practically given away have combined to make it easy to set up a site and climb aboard the Web.

However, building an attractive Web site, one that people will want to visit again and again, entails more than heaping good-looking graphics into an HTML document and hanging out your shingle on the Net. A good Web site is one that interacts with visitors dynamically, taking whatever they send to it and responding accordingly. That’s where this book comes in.

Tapping into the Power of Perl and CGI

Through the Common Gateway Interface (CGI), you can hook your Web pages up to Perl programs that process the information visitors send to you and tailor responses accordingly. The Perl programming language is a lovely tool for writing CGI applications; there are several reasons it’s been the vehicle of choice among Webmasters almost since it was introduced:

  Perl is extremely adept at manipulating text; easily 90 percent of CGI programming consists of text manipulation.
  Perl is easy to learn, even if you’ve never written a line of code in your life.
  Perl is portable, with most programs dropping unchanged into operating system platforms as widely varied as UNIX and Windows 95.
  Perl is freely available; a huge body of existing code is yours for the taking, usually for free, in any number of Internet repositories.

Through Perl and CGI, you can make your Web site truly dynamic. Your pages will do things, rather than simply displaying pretty pictures. Also, because CGI is an Internet standard and Perl is available for so many platforms, you encounter virtually no issues of system dependency, as you would with many of the proprietary Web page-processing tools. Every Web server understands CGI, and every popular computer system runs Perl programs.

How This Book Is Organized

The purpose of this book is to teach you the fundamentals of Perl-CGI programming and how you can use these tools to build a better Web site. It’s pretty difficult to learn programming without programming, so you’ll find copious examples of Perl code, with a special emphasis on how you hook the code up to a Web server through CGI. We’ll approach every task incrementally, building from simple concepts and examples up to complete projects that you can use in your Web site. The incremental approach will allow you to learn the basics of a concept easily; then you can flesh out the basics without having too many questions about what you’re doing. You’ll finish with a fundamental understanding of Perl and CGI, and enough knowledge to begin using your imagination to conjure up more complex tasks.

The topics we’ll cover include:

  The Perl basics, such as scalar and list variables, and the control structures the language provides.
  How CGI works and how it fits into the mix of your Web site.
  Perl and the Hypertext Markup Language (HTML) and how they are used together to create dynamic Web pages.
  Setting up a Web server.
  Building an access counter for your Web site.
  Using Perl regular expressions to do complicated text manipulations.
  Pairing a CGI application with HTML forms to build quizzes, polls, and a guest book.
  Using server-side includes to extend the power of HTML.
  Generating graphics on the fly with tools such as Ghostscript.
  Monitoring activity on your Web site through CGI and Perl.
  Creating and searching simple databases.
  Maintaining security on your Web site.

You won’t find much dry programming theory in this book. Instead, we’ll use a practical approach. Perl can be fun all by itself, but it’s more fun when you work with it to useful advantage. That’s precisely what you’ll do by following the examples presented in each skill; the result will be a nice bag of tricks for your Web site.

Code Examples and a Free Web Server

Copious code examples are instructive, but typing them can be copiously tedious. Not to worry, though: You can download all of the Perl programs and HTML documents you’ll encounter in the book from Sybex’s Internet site. Just go to www.sybex.com, click the NER series button and then the button for this book. A download button will appear.

You’ll also find a free Web server package at this site. Sambar’s fully functional freeware package—which is almost too good to be true, let alone free—is there for the taking along with the code examples. The Sambar server runs on Windows 95 and Windows NT.

At the end of each of this book’s skills you’ll find a special exercises for the Sambar server. The exercises are aimed at helping you apply what you’ve learned to your own Web projects.

What Are the Prerequisites?

As the book’s title explicitly states, there’s “no experience required” here. If you’ve never even seen a line of Perl code, you have nothing to worry about. You’ll learn about the language from the ground up; and when you’re finished, if you’ve been diligent, you’ll have a intermediate-level familiarity with Perl and understand how it can be used with CGI and your Web server to make a dynamic Web site.

You don’t need to be a programmer to benefit from this book. Obviously, any programming experience you have will add to your immediate understanding of the topics covered; C-language programmers especially will have very little trouble with Perl.

But the assumption in the book is that you haven’t done a lot of actual programming. You have enough experience with the World Wide Web to be interested in starting your own site, you know HTML well enough to have created some pages, and you know your way around the Web pretty well. Now you’re ready to take on something more meaty. This book will provide the meat.

The hardware and software requirements for the topics covered in the book are fairly loose. Even if you plan to run your Web site on your Internet service provider’s computer, you can use the Sambar server to run all of the examples presented in the book on your home computer. You can also use it to test any CGI applications you create on your own. (You must have Windows 95 or Windows NT installed on your computer to use the Sambar server.)

If you need more information, the Internet is a rich source. The Usenet newsgroups are a good place to start, notably at comp.lang.perl—Perl’s creator, Larry Wall, even shows up there from time to time.

Conventions Used in This Book

In each skill, you’ll find Notes, Tips, and Warnings that provide additional information about the topic being discussed. For example, these are used to point out something incidental to the discussion or to warn you about a potential programming pitfall.


NOTE:  Notes mark items of special interest and provide explanations of related topics, such as the format of a UNIX date string, or how to stop and start the Microsoft Internet Information Server to make configuration changes take effect.


TIP:  Tips are tidbits of information that will add to your understanding of a topic.


WARNING:  Warnings flag potential trouble spots that you might encounter in programming or with a procedure.

As you read through the book you’ll also encounter sidebars that offer information related to the topic at hand that might be too lengthy to fit in a note. You’ll find sidebars that cover topics such as the use of specific Perl functions and the logic behind hexadecimal numbering.

The Web’s a fun place (at least most of it is), and you can use this book to have even more fun with it. Who knows? Along with the skills you pick up here, you might even figure out how to do something that no one’s done yet. Anything goes on the Web. Use your imagination!


Table of Contents


Products |  Contact Us |  About Us |  Privacy  |  Ad Info  |  Home

Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc.
All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited.