Learning Perl on Win32 Systems

Learning Perl on Win32 SystemsSearch this book
Previous: 18.6 Troubleshooting CGI ProgramsChapter 18
CGI Programming
Next: 18.8 Further Reading
 

18.7 Perl and the Web: Beyond CGI Programming

Perl is used for much more than CGI programming. Other uses include logfile analysis, cookie and password management, clickable images, and image manipulation. And this list is still just the tip of the iceberg.

18.7.1 Custom Publishing Systems

Commercial web publishing systems may make things easy, especially for nonprogrammers, but they just aren't infinitely flexible the way a real programming language is. Without source code, you're locked into someone else's design decisions: if something doesn't work quite the way you want it to, you can't fix it. No matter how many whiz-bang programs become available for the consumer to purchase, a programmer will always be needed for those special jobs that don't quite fit the mold. And, of course, someone has to write the publishing software in the first place.

Perl is great for creating custom publishing systems tailored to your unique needs. You can easily convert raw data into zillions of HTML pages en masse. Sites all over the web use Perl to generate and maintain their entire web site. The Perl Journal (www.tpj.com) uses Perl to generate its pages. The Perl Language Home Page (www.perl.com) has nearly ten thousand web pages automatically maintained and updated by various Perl programs.

18.7.2 PerlIS and PerlScript

Each time a user invokes a CGI program or script, the web server needs to create a new instance of that program. While this is a reliable, proven way of doing things, there are more efficient ways to generate dynamic content. ActiveState provides for their distribution of Perl for Win32 two excellent alternatives. One is PerlIS, which enables Perl to be run as an ISAPI extension under an ISAPI compliant webserver (more on this shortly). Another is PerlScript, which is an ActiveX scripting version of Perl that can be used to generate Active Server Pages with a compatible web server (such as Microsoft's IIS or O'Reilly's Website Professional 2.0).

We said that PerlIS runs as an ISAPI extension. Accordingly, the web server loads Perl as part of its process when the web server starts. Each CGI request destined for the Perl interpreter is then run in-process with the web server as a separate thread. Consequently, the web server doesn't need to start a new instance of the Perl interpreter for each request; it merely creates a new thread and tells its copy of the Perl interpreter to handle the request from the new thread. This can provide significant performance benefits in situations where the server receives a high number of hits.

The current version of PerlIS (Build 306) has some instability when launching external processes and when creating socket connections. If you can't get something to work that you need, we suggest running your script as a CGI program using the standalone interpreter. Look for improved stability in future releases of PerlIS.

PerlScript can not only be used to generate Active Server Pages, but also as a client-side scripting language in the same manner as VBScript or JavaScript. For more information on PerlScript, see www.activestate.com. For more information on Active Server Pages, see the Microsoft ASP roadmap at www.microsoft.com/iis/usingiis/resources/ASPdocs/roadmap.asp, which provides a detailed overview of Active Server Pages and the automation objects that a server provides to PerlScript.


Previous: 18.6 Troubleshooting CGI ProgramsLearning Perl on Win32 SystemsNext: 18.8 Further Reading
18.6 Troubleshooting CGI ProgramsBook Index18.8 Further Reading