Writing CGI Applications with Perl 1st Edition
| Kevin Meltzer (Author) Find all the books, read about the author, and more. See search results for this author |
| Brent Michalski (Author) Find all the books, read about the author, and more. See search results for this author |
Use the Amazon App to scan ISBNs and compare prices.
Editorial Reviews
From the Back Cover
Writing CGI Applications with Perl offers the most practical examples of applying Web programming techniques to real world problems I've seen yet. The text blends good CGI programming techniques, idiomatic Perl, and databases into many large and useful examples. Careful attention is paid to demonstrating solid, scalable code for production use. This is not your typical 'Hello, World' CGI programming book.
--Clinton Pierce, Perl trainer and author of Teach Yourself Perl in 24 Hours
With its sophisticated database, network, and multi-platform capabilities, the Perl programming language has emerged as an ideal tool for developing CGI-based Web applications.
Writing CGI Applications with Perl shows you how to use Perl to accomplish the most vital tasks needed for today's online applications. Using numerous examples, line-by-line code explanations, and skill-stretching exercises, this book not only provides useful cut-and-paste code for your own programs, but it also teaches you practical skills and techniques that will enable you to develop any kind of CGI-based Web application with Perl.
Focusing on the most important areas of Web application development, including database interaction, form and file handling, security, e-mail, and graphics, the book provides in-depth coverage of such specific topics as:
- Working with HTML Web forms and obtaining user input
- Cookies, tracking clicks, and access counters
- Using the mod_perl Apache module
- Connecting to a POP3 server for e-mail
- Perl DBI and databases on the Web
- Tying a hash to a database
- Embedding Perl in HTML with HTML:: Mason
- Remote file management via the Web
- Creating dynamic images
- XML and its derivatives, RSS and RDF
In addition, introductory material is provided for newcomers to CGI or Perl. Numerous appendices include handy references as well as a guide to Perl documentation. A companion Web site, http: //www.perlcgi-book.com, contains the code for all the examples.
Geared toward the needs of today's professional Web developers, Writing CGI Applications with Perl provides the specific tools, experienced-based techniques, and overall concepts necessary for quality Web application development.
0201710145B04062001About the Author
Kevin Meltzer has been using Perl since the early '90s for everything from CGI and system administration to database migrations and report generation. He considers himself a "Perl evangelist," and is the founder of the Hartford Perl Mongers (although he now resides in Florida). Kevin has been published in The Perl Journal, and is the judge of their annual Perl Poetry Contest. He is now working for Verio, Inc. as a Perl developer/engineer.
Brent Michalski discovered Perl around 1994 and has been programming in it ever since. He considers himself a "Perl freak" and loves sharing Perl with others. Brent mainly develops CGI applications because he enjoys the Web so much. He has written articles for Web Review, and currently maintains the Perl area on the Dr. Dobb's Journal Web site. Brent is a senior developer at MasterCard International where they let him play with Perl every day.
0201710145AB04062001Excerpt. © Reprinted by permission. All rights reserved.
Purpose of this Book
Perl's popularity as a CGI scripting language is growing by leaps and bounds. However, there are few books available today that cover this subject in depth including a broad range of concepts. We wanted our book to help people learn to use Perl and convince them that it is the best choice for their Web-based applications. The goal of this book is not to teach the Perl language--although certain tricks and features may be learned--but to show how Perl can accomplish the tasks needed for many of today's online applications. In short, we wanted to provide a resource that not only teaches new uses of Perl but challenges the reader with exercises that use the concepts. Standard Perl documentation is also provided. The book covers a wide range of concepts, and using these, you should be able to write almost any Perl/CGI application with the techniques provided.
This book is different from others about Perl and CGI. It takes a cumulative approach and introduces applications that use concepts learned in previous chapters. Each chapter will cover at least one specific Web-based application and explain the code line by line (or block by block) so you not only learn what the scripts are doing but how they are doing it. And in order to help induce self-learning and application building, each application is working but incomplete. We provide skeleton applications that can stand on their own, but we leave out certain features that can be added (and we suggest adding them in the exercises) using the information in that chapter and in previous chapters. Our goal is not to give you "cut and paste" software but rather to show you how to write the software yourself.
Chapter Summaries
Chapter 1, Perl, CGI, and this Book. This chapter explains what Perl and CGI are. It also supplies more detail about this book and shows how to use the CPAN module.
Chapter 2, What You Should Know. We don't expect the reader to know everything, but we do expect at least a base level of knowledge. This chapter outlines what you should already know and explains a few things that you may not already know but should to get the most out of this book, such as tainting, security concerns, and troubleshooting.
Chapter 3, Using Your Environment. Many times in CGI applications you need information from the client, such as IP address or browser information. This chapter covers how to access the Web server environment variables and what they mean.
Chapter 4, Introduction to Web Forms. There are few online applications where there is not some sort of Web form used to allow an end user to submit information. Chapter 4 explains the HTML elements of creating a Web form, as well as how to obtain the user input.
Chapter 5, Working with Cookies. Using cookies to store data on a Web client can be very useful to record the preferences of and remember things about users. You will learn how to set, get, and use cookies in this chapter.
Chapter 6, Access Counters. Many people want to count how many people come to their Web site. The examples in this chapter show you how to do this.
Chapter 7, Web-Based File Uploading. Here you will learn how to safely allow end users to upload files to a server from their local hard drives.
Chapter 8, Tracking Clicks. It can sometimes be useful to know what links on a Web site are being followed and from where. The examples in this chapter show how to track these clicks.
Chapter 9, Using mod_perl. The popular mod_perl Apache module can be extremely useful when it is appropriate for an application. You will see how to configure mod_perl, as well as how to use and write mod_perl Perl modules.
Chapter 10, Web-Based E-mail. The examples in this chapter demonstrate how to connect to a POP3 server to view e-mail, view attachments, and send e-mail via the Web.
Chapter 11, Introduction to DBI and Databases on the Web. Chapters 1–10 presented basic uses for database connectivity in previous examples. This chapter examines the Perl DBI in more depth.
Chapter 12, Tied Variables. The magic of tying data structures to variables and how to do this when the data structure is a database is explained in this chapter.
Chapter 13, Embedding Perl in HTML with Mason. This popular tool is examined and explained. This chapter shows you how to embed Perl within HTML and use the HTML::Mason module to speed up development and maintenance time.
Chapter 14, Document Management via the Web. By now you will have learned how to upload files to a server. This chapter shows you how to manage your files remotely via the Web.
Chapter 15, Dynamically Manipulating Images. Creating charts, graphs, thumbnails, and galleries, and changing images on the fly are all concepts that can be useful in CGI applications. This chapter shows you how to add these techniques to your software.
Chapter 16, RSS and XML. XML is another tool that is gaining in use and popularity. This chapter shows you how to use both XML and a derivative of it, RSS and RDF, to share information and use in applications.
Appendix A, Server Codes. Learn what the codes returned by a Web server mean.
Appendix B, Environment Variables. This is a list of the most common Web server environment variables.
Appendix C, POSIX::strftime() Formats. This book uses the POSIX module a few times to format date strings. This list shows the formats that the module uses and what the formats do.
Appendix D, General Public License. If you didn't read the copy that came with Perl, you can do so here.
Appendix E, Artistic License. Another license under which Perl is distributed.
Appendix F, Perl Documentation. A list of the documentation that comes with Perl. This list is useful for interactive learning along with this book.
Appendix G, ASCII Codes. A list of ASCII, hex, and decimal codes.
Appendix H, Special HTML Characters. A list of special characters, such as £, ®, and Æ. Although these aren't specific to Perl, you will probably need some of them sooner or later when generating HTML with Perl.
Other Resources
One of the best resources for Perl is the Perl documentation and the documentation included in various Perl modules. Chapter 1 covers how to read this documentation with the perldoc command. The Perl homepage at http://www.perl.com is extremely useful with articles, tips, documentation, other resource links, and what's new in the world of Perl. The Perl Mongers homepage at http://www.perl.org supplies good information on the world of Perl and Perl advocacy. The use Perl Web site at http://use.perl.org is a community page where Perl information is shared and discussed. The Perl Documentation Web site at http://www.perldoc.com is a very useful site containing the latest Perl documentation. Finally, the Perl Monks at http://www.perlmonks.com is another community where people can ask questions, answer questions, chat, and share knowledge.
Usenet has Perl newsgroups that are also useful: comp.lang.perl.announce has Perl announcements; comp.lang.perl.misc is a high traffic list for asking Perl-related questions; and comp.lang.perl.modules announces and discusses Perl modules. A non-Perl-specific news group that deals with CGI is comp.infosystems.www.authoring.cgi. Here you can discuss all topics CGI.
Contacting Us
We would love to hear from you. You can find information on this book and errata at http://www.perlcgi-book.com and http://www.awl.com
0201710145P04062001
I'd like to read this book on Kindle
Don't have a Kindle? Get your Kindle here, or download a FREE Kindle Reading App.
Product details
- Publisher : Addison-Wesley Professional; 1st edition (February 25, 2001)
- Language : English
- Paperback : 560 pages
- ISBN-10 : 0201710145
- ISBN-13 : 978-0201710144
- Item Weight : 2.1 pounds
- Dimensions : 6.41 x 1.17 x 9.97 inches
- Customer Reviews:
About the authors

Discover more of the author’s books, see similar authors, read author blogs and more

Discover more of the author’s books, see similar authors, read author blogs and more
Customer reviews
Top reviews from the United States
There was a problem filtering reviews right now. Please try again later.
This is a great book of useful, real-world CGI examples. As long as you already know Perl (you must have a decent familiarity with the language and some scripting background to really use this book well, or else you will get overwhelmed!!!) this is a perfect way to go from theory to practice in just a few easy steps.
The problem, of course, with most Perl CGI books is that they are written by people who just don't know very much Perl. That's certainly not the case here. Both Kevin and Brent are well-respected members of the Perl community and they know what they are talking about when it comes to writing CGI programs in Perl.
Another common mistake in Perl CGI books is that the authors try to take people who know a bit of HTML and teach them programming, Perl and CGI all at the same time. The authors of this book realise that this approach is likely to lead to, at best, patchy understanding of any of these concepts so they aim there book at people who are already programmers and who have some knowledge of Perl. This means that they can concentrate of teaching the parts of Perl that are useful when writing CGI programs.
One corner that is often cut when discussing CGI programming is security. This is a very dangerous approach to take as a badly written CGI program can leave your web server open to attack from anyone on the Internet. That's not a mistake that is made here as the authors introduce security in chapter 2. Add to that the fact that the code examples all use -w, use strict and CGI.pm and the book is already head and shoulders above most of its competition.
Early chapters look at common CGI requirements such as file uploads and cookies. Each chapter is full of well written (and well-explained) sample code. The example of an access counter in chapter 6 even locks the file containing the current count - this is possibly a first in a Perl CGI book!
By the middle of the book we have already moved beyond simple CGI programming and are looking at mod_perl. This chapter covers both the "faux-CGI" Apache::Registry module and also writing complete mod_perl handlers.
In the second half of the book we start to look at some bigger examples. The authors present a web-based email system and even a shopping cart. In order to fit these examples into their respective chapters a couple of corners have been cut, but there's enough information there to enable anyone to write the complete systems.
Chapter 13 introduces the HTML::Mason module as a way to separate content from presentation. It's obvious that the author's are big fans of this module and this leads to my only real criticism of the book. At no point do they mention the fact that the same benefits can be gained from using any of half a dozen templating systems found on the CPAN. I would have been a lot happier if they had mentioned things like Text::Template, HTML::Template and the Template Toolkit before picking HTML::Mason as the system for their example.
There are then two more long chapters with examples of a document management system and image manipulation software. Once more the code in these examples would serve as a greating starting point for anyone wanting to implement something along these lines. The last chapter looks at XML and, in particular, the use of RSS files to provide data feeds to other web sites.
All in all this is a very useful book for someone wanting to write web-based applications using Perl. It's packed full of good advice and code that follows all of the best practices for writing CGI programs in Perl. This book won't teach you Perl, but if you've read Learning Perl or Elements of Programming with Perl then you'll find this book easy enough to follow.
All the various CGI tricks I'd known and used that weren't mentioned in this book, were the sort of thing that a beginning programmer might misuse, and thereby accidentally create a way for some malicious user to, for example, delete or corrupt any file on the filesystem, or order any product for [price]. Since /most/ beginning programmers create programs with just those kind of accidental security problems, I'm glad that this book sees security as a primary goal.
In other words: they show you how to do anything you need in CGI, but they don't give you enough rope to hang yourself with! The other thing that makes me happy with this book is that it wisely takes the (very realistic) perspective that CGIs are programs that have to do something /besides/ just talking to the Web browser -- they have to access a database, send a piece of mail, read from a config file, write to a log file, or whatever other details the task demands. That's just the way the CGI business is, and this book gives you a nice introduction to that way of programming.
I heartily recommend this book for anyone who's starting out doing CGI programming. It assumes you do know some Perl already. If you don't, and you already have a strong programming background in some other language than Perl, can probably just make do with the Perl man pages; but less experienced folks should get /Learning Perl/, or /Elements of Programming with Perl/, or maybe even /Teach Yourself Perl in 24 Hours/ (which has a good CGI section, incidentally).
One note: currently this book is in its first printing, so there are, as always, typos. The errata list at perlcgi-book.com was quite helpful.

