Previous Page TOC Index Next Page See File

How To Use This Book

This book starts where most CGI tutorials leave off—just before you get into the really cool stuff! Fear not. If you are looking to take your Internet knowledge to the next level, you've made the right purchase. This book provides useful tips and hands-on examples for developing your own applications within the CGI programming environment using the Perl language. You get a complete understanding of the important CGI concepts, such as HTTP request/response headers, status codes, CGI/URI data encoding and decoding, and Server Side Include commands. You learn application development through examples in every chapter and with a complete application when you design an on-line catalog.

Specific features that you'll see throughout the book follow:


Do/Don't boxes: These give you specific guidance on what to do and what to avoid doing when programming in the CGI environment and Perl.


Notes: These provide essential background information so that you not only learn to do things within the CGI environment and Perl, but have a good understanding of what you're doing and why.


Tips: It would be nice to remember everything you've previously learned, but that's just about impossible. If there is important CGI or Perl material that you have to know, these tips will remind you.


Warnings: Here's where the author shares his insight and experience as a professional programmer—common bugs he has faced, time-saving coding techniques he's used, and pitfalls he's fallen into. Learn from his experiences.

Who Should Read This Book

Anyone who wants to know about programming on the Internet and in the CGI environment will benefit by reading this book. You spend several days covering advanced topics, yet a majority of this book is dedicated to helping you understand the CGI environment and Perl and then applying that knowledge to real applications. It is this hands-on approach to the CGI environment and the Perl language that sets this book apart from others. In addition to helping you develop an application, you learn the concepts involved in development.

Conventions

Commands, parameters, listings, and on-screen messages appear in a special typeface. Things that you should type appear in boldface. New terms are introduced in italics.

Teach Yourself CGI Programming with Perl in a Week

Teach Yourself CGI Programming with Perl in a Week

Eric Herrmann

Sams.net

201 West 103rd Street

Indianapolis, Indiana 46290

Wives are great people. They kick you, push you, and hug you when you need it the most. My wife, Sherry, is a great people. She has typed for me, encouraged me, and kept me going when I was most tired and grumpy. Thanks for the kicks, the hugs, and the willingness to push when I needed it. I love you.

Copyright © 1996 by Sams.net Publishing

FIRST EDITION

All rights reserved. No part of this book shall be reproduced, stored in a retrieval system, or transmitted by any means, electronic, mechanical, photocopying, recording, or otherwise, without written permission from the publisher. No patent liability is assumed with respect to the use of the information contained herein. Although every precaution has been taken in the preparation of this book, the publisher and author assume no responsibility for errors or omissions. Neither is any liability assumed for damages resulting from the use of the information contained herein. For information, address Sams.net Publishing, 201 W. 103rd St., Indianapolis, IN 46290.

International Standard Book Number: 1-57521-009-6

Library of Congress Catalog Card Number: 95-70879

99 98 97 96 4 3 2 1

Interpretation of the printing code: the rightmost double-digit number is the year of the book's printing; the rightmost single-digit, the number of the book's printing. For example, a printing code of 96-1 shows that the first printing of the book occurred in 1996.

Printed in the United States of America

All terms mentioned in this book that are known to be trademarks or service marks have been appropriately capitalized. Sams.net Publishing cannot attest to the accuracy of this information. Use of a term in this book should not be regarded as affecting the validity of any trademark or service mark.

President, Sams Publishing

Richard K. Swadley

Publisher, Sams.net Publishing

George Bond

Publishing Manager

Mark Taber

Managing Editor

Cindy Morrow

Marketing Manager

John Pierce

Acquisitions Editor

Mark Taber

Development Editor

Fran Hatton

Software Development Specialist

Merle Newlon

Production Editor

Fran Blauw

Technical Reviewer

Eric Garrison

Editorial Coordinator

Bill Whitmer

Technical Edit Coordinator

Lynette Quinn

Formatter

Frank Sinclair

Editorial Assistant

Carol Ackerman

Cover Designer

Jason Grisham

Book Designer

Alyssa Yesh

Production Team Supervisor

Brad Chinn

Production

Michael Brumitt, Mona Brown,

Jeanne Clark, Brad Dixon,

Judy Everly, Jason Hand,

Sonja Hart, Mike Henry,

Ayanna Lacey, Clint Lahnen,

Kevin Laseau, Paula Lowell,

Steph Mineart, Ryan Oldfather,

Nancy Price, Laura Robbins,

Bobbi Sattterfield, Dennis Sheehan,

Craig Small, Laura Smith,

Dan Swenson, Tina Trettin,

Susan Van Ness, Mary Beth Wakefield,

Todd Wente, Colleen Williams,

Jeff Yesh

Indexer

Brad Herriman

Overview

Day 1 Getting Started

Chapter 1

An Introduction to CGI and Its Environment

Chapter 2

Understanding How the Server and Browser Communicate

Day 2 Learning the Basics of CGI

Chapter 3

Using Server Side Include Commands

Chapter 4

Using Forms to Gather and Send Data

Day 3 Understanding CGI Data Management

Chapter 5

Decoding Data Sent to Your CGI Program

Chapter 6

Using Environment Variables in Your Programs

Day 4 Putting It All Together

Chapter 7

Building an On-Line Catalog

Chapter 8

Using Existing CGI Libraries

Day 5 Using Applications that Make Your Web Page Cool

Chapter 9

Using Image Maps on Your Web Page

Chapter 10

Keeping Track of Your Web Page Visitors

Day 6 Using Applications that Make Your Web Page Effective

Chapter 11

Using Internet Mail with Your Web Page

Chapter 12

Guarding your Server against Unwanted Guests

Day 7 Looking At Advanced Topics

Chapter 13

Debugging CGI Programs

Chapter 14

Tips, Tricks, and Future Directions

Appendixes

A

Mime Types and File Extensions

B

HTML Forms

C

Status Codes and Reason Phrases

D

The NCSA imagemap.c Program

Index

Contents

Acknowledgments

It's not possible to write a book without a lot of help from all kinds of places:

About the Author

Eric Herrmann is the owner of Practical Internet, an on-line catalog and Web-page development company, and partner in Advanced Software Solutions LLC., a software development company. Eric has a Masters degree in Computer Science, 10 years of application programming experience in various asynchronous parallel processing environments, and is fluent in most of today's buzzwords: OO, C++, Unix, TCP/IP, Perl, and Java. Eric is happily settled on 10 acres of lovely Texas hill country in Dripping Springs, Texas, with his wife, Sherry, a riding instructor who speaks fluent horse; his three children, Scott (17), Jessica (8), and Steve (7); 10 horses (I think), 3 dogs, 4 cats, and 8 pet chickens :). When not playing at his computer, Eric helps with the horses, takes the kids fishing, or plays with model trains in the garage.

Introduction

Teach Yourself CGI Programming with Perl in a Week collects all the information you need to do Internet programming in one place.

In the first chapter, you will learn:

From there, you will learn about the basic client/server architecture of the server, and you will get a detailed description of the HTTP request/response headers. You will learn the client/server model in straightforward and simple terms, and throughout the book, you will learn about several methods for keeping track of the state of your client.

A full explanation of the unique environment of CGI programming is explained in the chapters covering environment variables and server communications with the browser. The heart of CGI programming—understanding how data is managed between the client and the server—gets full coverage. Each step in data management—sending, receiving, and decoding data—is fully covered in its own chapter.

Each chapter of Teach Yourself CGI Programming with Perl in a Week includes lots of programming and HTML examples. This book is an excellent resource for the novice Perl programmer; a detailed explanation of Perl is included with most programming examples. There is no assumption of the programming skills of the reader. Every programming example includes a detailed explanation of how the code works.

After teaching you the foundations of CGI programming, this book explores and explains the hottest topics of CGI programming. Make your Web page come alive with a clickable image map. Learn how to define the hot spots, where the existing tools are, and how to configure your server for image maps. Count the number of visitors to your Web page and learn about the pitfalls of getting their names. Learn how to create customizable mailing applications using the Internet sendmail format. And learn how to protect yourself from hackers, in a full chapter on Internet and CGI security.

You will find this book a great introduction and resource to the CGI programming environment on the Internet. Read on to begin understanding this fantastic programming environment, and good luck in all your programming endeavors. Have Fun! It's more fun than not having fun.

Previous Page TOC Index Next Page See File