MySQL and Perl for the Web: Chapter 3 Section 3 (1/6) | WebReference

MySQL and Perl for the Web: Chapter 3 Section 3 (1/6)

current pageTo page 2To page 3To page 4To page 5To page 6

Improving Performance with mod_perl

Writing mod_perl Scripts

In general, writing CGI scripts to run under mod_perl doesn't differ much from writing them for execution under a standalone Perl process. Therefore, if you create a standalone script in the cgi-bin directory, you often can expect that moving it to the cgi-perl directory won't cause problems, the script will just run faster. The script we used earlier to test the mod_perl configuration was an example of this: It functioned properly whether run from cgi-bin or from cgi-perl. You can try this with other scripts as well. For example, you can move the scripts developed in Chapter 2 from cgi-bin to cgi-perl to see they work properly.

That's not to say that there are never any problems using CGI scripts under mod_perl. This section describes things to guard against so your scripts don't cause problems for themselves, other scripts, or your Web server. It discusses the issues you should be aware of for the applications in this book. You might trip over others in your own scripts, however; so for additional information, check the mod_perl_to_cgi and mod_perl_traps documents listed in Appendix B.

Script-Writing Shortcuts

When you write scripts for mod_perl, you can use certain shortcuts as compared to writing them for standalone execution:

Of course, if you take advantage of these shortcuts, you'll need to add the #! and use lib lines back in if you decide later to use your scripts as standalone CGI programs (for example, to use them on a host that supports only that execution mode). In this book, scripts written for mod_perl will begin with the #! line and will include any necessary use lib line, even though they don't strictly need them. That way you'll more easily be able to use them even if you don't install mod_perl, by moving them to the cgi-bin directory instead.

current pageTo page 2To page 3To page 4To page 5To page 6

Created: July 13, 2001
Revised: July 13, 2001