O'Reilly logo

Web, Graphics & Perl/Tk Programming by Jon Orwant

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 5. mod_perl

Lincoln D. Stein

Doug MacEachern

One of the minor miracles of the World Wide Web is that it makes client/server network programming easy. With the Common Gateway Interface (CGI), anyone can create dynamic web pages, frontends for databases, and even complex intranet applications with ease. If you’re like many web programmers, you started out writing CGI scripts in Perl. With its powerful text-processing facilities, forgiving syntax, and tool-oriented design, Perl lends itself to the small programs for which CGI was designed.

Unfortunately, the love affair between Perl and CGI doesn’t last forever. As your scripts get larger and your server more heavily loaded, you inevitably run into a performance barrier. A thousand-line Perl CGI script that runs fine on a lightly loaded web site becomes unacceptably slow when it increases to 10,000 lines and the hit rate triples. You might even have tried switching to a different programming language—and been disappointed. Because CGI relaunches the script every time it’s requested, even compiled C won’t give you the performance boost you expect.

If your applications go beyond simple dynamic pages, you might have run into the limitations of the CGI protocol itself. Many interesting things happen deep inside web servers, such as the smart remapping of URLs, access control and authentication, and the assignment of MIME types to documents. The CGI protocol doesn’t give you access to these internals. You can neither find out what’s ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required