CGI and Perl

Introduction and Overview

It's more than a little bit intimidating to take on the task of writing an intermediate-to-advanced-level tutorial on the subject of World Wide Web programming. The current level of innovation and the rate at which new ideas and techniques are being implemented on the Web is nothing less than exponential. Each new idea or new technique has the potential for adding to or enhancing the vast structure that already is the Web, or refining that structure, making it potentially less cumbersome and easier to understand. Some ideas are adopted as standards, and others fizzle and die lonely little deaths, for lack of use or interest.

Now, with all of that said, we're going to refine our task (thankfully) to the exploration and discussion of Web innovations related to Perl, the general purpose scripting language which is widely used and loved by many people all over the world. We'll also generally limit this work to discussions and examples which implement the features and functionality of Version 5 of Perl, which is the latest and greatest release.

So, that would seem to carve out a nice little niche, yes? Even though this seems like a relatively small development space to confine one's research to, it in fact includes the vast majority of the Web tools and innovations which are being used out there. Perl, and specifically Perl5 is, in fact, the cornerstone of the interactive Web as it exists today. The many ways that people use Perl to implement the features and functionality of their Web pages are as dynamic and subject to innovation, enhancement, and errors, and lonely deaths, as any other component of the Web in general, and probably even more so.

"So why bother?" you might ask. If any such undertaking might be outdated and possibly even moot, by the time it is finished, then what's the point in attempting it in the first place? There are two primary reasons why this is true. The first is that Perl, as a programming language, wasn't designed with the Web in mind at all. It's been around for a long time, at least in "Internet Years," but its first and primary function was, and still is, according to its author, Larry Wall, "Text processing the UNIX way." In fact, that's where it got its name, as PERL stands for Practical Extraction and Report Language.

The first release of Perl5 just happened to coincide with the explosion of popularity of the HTTP/HTML server/protocol, and now everybody seems to have a Web page. And what's a Web page without a little CGI to give the browser some entertainment, or gather some data, or, yes, even make a sale or two. Now, there are plenty of ways to write a CGI script, but the most popular, for its ease of use, security features, and now with version 5, reusable modules, is Perl.

As we've said, the Web is dynamic, and always changing, especially in these, its early years. It's hard to believe sometimes, at least for me, but the Web is still but a toddler as a technology and protocol. There are a lot of things which are still being decided at high levels, to add functionary, reduce bandwidth, and generally enhance the specifications of the protocol which is HTTP, and CGI. Some commercial entities, like Netscape, have even taken it upon themselves to implement features and functionary in their own browsers and servers which haven't been formally adopted. This has generally been a good thing, from our standpoint, but it does fly in the face of the long-standing tradition of the discussion and adoption of new techniques/features in any protocol. Regardless, given their market share, they do seem to have some leeway.

Similarly, Perl is a dynamic entity. The new object oriented features and capabilities which come with Perl, and the tremendous amount of work which has been done to design and implement reliable "class libraries," or modules, to take advantage of these features can definitely be considered a "work in progress." Enhancements, patches, and new features are coming along almost daily. Occasionally this may lead to a bit of confusion, and sometimes incompatibility, with the current status or version of a given Perl5 module. It's sort of up to you, as a Perl user, to try to keep up with the latest changes. It's up to us, as the authors, to try to help you understand how to do that.

We don't expect to go through umpteen reprints, as a truly lasting bit of prose or a high-minded mathematics text might. We do expect to be able to look back when we're done and be able to say that, as of that date, we wrote about the most widely used and accepted techniques, and that we covered most of the latest and most promising developments that relate to Web programming with Perl5, minimally providing you with a means to keep up with them, their implementation, and their implementors. We sincerely hope that the concepts, techniques, and technologies which we choose to write about here will indeed be among the ones which last. But only time will tell.

So, here we go...

by BrainBellupdated