|
The
Story of CGI & PERL
CGI
A few years back,
there was a craze for "interactive
books"--game programs in which you'd skip to a
specific page in the book, based on some choice you had
to make. Without scripting, the Web would be only as
interactive as one of those games. Content laid out in
this way is called browsable content. Although
it's quite useful for some applications, this format can
be very restrictive and does not allow for true
interactivity. With only browsable content, your Web
experience would be limited to the preconceived
scenarios of the Web site author.
Scripts permit two-way
interaction between the Web site and the user browsing
the site. This gives Web site authors a lot more
flexibility: They can write scripts that obtain specific
information from you and act on that information. A
script can even be used to build games and other
interactive programs.
PERL
Practical
Extraction and Report Language --- more commonly (and
more easily) referred to as Perl, is the simple, free,
text-processing programming language that pushes much of
the Web's interactivity. If you see a form, a drop-down
list, or other simple interactive element that includes
a box inviting you to enter text or to perform a search,
chances are you're looking at the product of script
written in Perl.
A Grass Roots
Language
Although a single programmer, Larry Wall, wrote the
original version of the language, the Perl-programming
community on the Web is huge, and it has exerted a
tremendous amount of influence on subsequent versions of
the language.
In the face of
marketing-fueled languages like ActiveX,
Java,
and JavaScript,
Perl is an enormously popular, yet low profile,
grassroots success story.
Perl Appeal
Since they don't need to be compiled prior to running,
interpretive languages like Perl have some advantages
where programming ease and portability are concerned. As
an interpretive language that also happens to excel at
processing text, Perl is a natural choice for writing
CGI scripts --- the mini-programs responsible for much
of the interaction between a Web site user and the Web
site's server.
Perl
& CGI
While you hear many people talk about Perl and CGI
almost interchangeably, they are not at all the same
thing. The Common Gateway Interface (CGI) allows
information to pass between a Web site's server and a
program (written in Perl or another language) that lives
in the "CGI bin" on that server. You send
information from your browser to the server; the server
passes the information through the CGI gateway to the
Perl program; the Perl program does its thing to the
information (perhaps conducting a query of a database
and creating an HTML page that lists the results), then
sends the information back through the CGI gateway to
the server, and the server returns the product to your
browser. And it all happens in a matter of milliseconds,
if everything's running smoothly. Whew.

|