Writing CGI Application with Perl

Writing CGI Application with Perl

5.0 5
by Kevin Meltzer, Brent Michalski

ISBN-10: 0201710145

ISBN-13: 9780201710144

Pub. Date: 02/15/2001

Publisher: Addison-Wesley

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

…  See more details below


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.


Read More

Product Details

Publication date:
Product dimensions:
7.40(w) x 8.89(h) x 0.78(d)

Table of Contents




1. Perl, CGI, and this Book.

What Is Perl?

What Is CGI?

Why Perl Is Good for CGI.

About this Book.

Who Is this Book For?

Conventions Used in this Book.

Using perldoc.

Using the CPAN.

2. What You Should Know.



File Permissions.

Basic Security Concerns.

Using -T.

Checking for Taintedness and Laundering Data.

Your PATH and -T.

Installing a Script.



The Expires HTTP Header.

Cache-Control HTTP Header.


3. Using Your Environment.

Introduction to %ENV.

Adding to %ENV.

Form Input Primer.

Example Script: Visitor Log.

Example Script: Basic Report.

Reader Exercise.

What Have We Learned?


4. Introduction to Web Forms.


Form Tags.

Reading Form Input with CGI.pm.

Making Your Users Happy.

Final Example.

User Exercises.

Program Listings.

5. Working with Cookies.




Cookie Pieces.

Working with Cookies the Manual Way.

Baking Cookies with CGI.pm.

Controlling User Preferences with Cookies.

User Exercises.

6. Access Counters.


Example Script: SSI Text Counter.

Example Script: SSI Image Counter.

Example Script: SSI Text Counter, with a Twist.

Example Script: An Imageless Image Counter.

Counter Conclusion.

Reader Exercises.


7. Web-Based File Uploading.


File Uploading Basics.

Viewing Files.

Uploading Multiple Files.

Reader Exercises.

File Listings.

8. Tracking Clicks.


Example Script: A Simple Click Tracker.

Example Script: Random Images.

Example Script: Click Tracking (Reprise).

Reader Exercises.


9. Using mod_perl.

What Is mod_perl?

Configuring mod_perl.


Automatic Headers and Footers with Apache::Sandwich.

A mod_perl Photo Album with Apache::Album.

Authentication with Apache::AuthDBI.

Writing a mod_perl Handler.

Reader Exercises.


10. Web-Based E-mail.


Example Script: Checking POP3 Mail via the Web.

Example Script: Reading E-mail via the Web.

Example Script: Displaying Attachments.

Example Script: Composing E-mail.

Reader Exercises.


11. Introduction to DBI and Databases on the Web.


Using the Perl DBI.

Connecting to the Database.

Disconnecting from the Database.

Preparing and Executing an SQL Query.

Fetching Data.

The fetchall_arrayref( ) Method.

The fetchrow_arrayref( ) Method.

The fetchrow_hashref( ) Method.

The bind_columns( ) Method.

Putting It All Together.

The do( ) Method.

Wrapping It Up.

Reader Exercises.


12. Tied Variables.


Setting It All Up.

Getting Started.

Diving In.

The Main Program.

Finishing the ShopCart Module.

Running the Program.

Wrapping It Up.

Program Listings.

13. Embedding Perl in HTML with Mason.



The Strategy.

Mason Syntax.

Special Mason Components.

Cascading Execution.

Moving Right Along.




Wrapping It Up: The Code for the Example Site.

14. Document Management via the Web.


The Plan.






Program Listings.

15. Dynamically Manipulating Images.


Adding Shapes and Text.

Creating a Dynamic Graph.

Creating Thumbnail Images.

Filtering Images with Image::Magick.

Animated Images.

Reader Exercises.


16. RSS And XML.

XML and RSS Overview.

Structure of an XML Document.

News Portals with RSS.

A Home Page News Portal.

Creating an RSS File.

Reader Exercises.


Appendix A. Server Codes.

Provide confirmation that a request is being processed.

Request was performed.

Request not performed.

Request is incomplete.

Internal server errors.

Appendix B. Environment Variables.

Appendix C. POSIX::strftime( ) Formats.

Appendix D. General Public License.

Appendix E. Artistic License.

Appendix F. Perl Documentation.

Appendix G. ASCII Codes.

Appendix H. Special HTML Characters.


Index. 0201710145T04062001

Read More

Customer Reviews

Average Review:

Write a Review

and post it to your social network


Most Helpful Customer Reviews

See all customer reviews >

Writing CGI Application with Perl 5 out of 5 based on 0 ratings. 5 reviews.
Guest More than 1 year ago
This is an extremely helpful book for writing web-based applications with Perl. Lots of helpful descriptions and examples. Useful for beginners to familiarize themselves with a wide range of necessary terms and topics. For example, I found the chapters on mod_perl and dbi very helpful. Also useful for more experienced CGI programmers because of the useful examples and techniques presented.
Guest More than 1 year ago
This book is well written and is mostly a set of well explained examples on CGI programming with Perl, plus some explanation of CGI. It is not a Perl textbook, but it does explain the examples line by line. I'm new to CGI and have only recently learned Perl, but I was able to add several CGI-based features to my web site after reading this book. Highly recommended.
Guest More than 1 year ago
I've read several Perl books in my time, and this is by far the best one I've seen. It covers the major aspects of Perl thoroughly, with short and well-explained examples. A programmer or developer can pick up this book and learn Perl the right way, rather than learning inefficient hacks taught in other books.
Guest More than 1 year ago
My 5-star rating assumes you put in the time and effort the book expects of the reader. Do the exercises. Accept the challenge to improve script. Look at documentation. I will use the book as a reference source or even to find code I need. That's not what makes this a 5-star book. What does are how straight-forward the authors' explain how the script accomplishes the task; the different methods used for getting the message across; the clarity of the writing and flow of the book's substance; and the volume of material covered. I couldn't have made a better investment in expanding my knowledge.
Guest More than 1 year ago
This book does what I expected and more. It offers practical cut-and-paste script, but focuses as much on ¿why¿ a technique works so you can write your own script and think of new tasks for Perl. The book covers many applications: graphics,cookies, e-mail, security, databases, and much more. The authors present info in a unique way, such as with interactive exercises. They successfully introduce techniques and concepts as building blocks for other applications. You're not expected to know something that's not in the book. To wrap up, I recommend this terrific book to all programmers or web developers who want to keep on learning.