![]() |
![]() |
![]() |
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
![]() |
![]() |
To access the contents, click the chapter and section titles.
Perl CGl Programming: No experience required.
Perls Ancient HistoryThere is only one reason that Perl programsor scripts, which is a lexical convention that will be explained shortlyare so universal in World Wide Web programming. The simple fact of the matter is, until the last few years, virtually every Web server in existence was running on a UNIX system and Perl is among the most useful of UNIX tools. The first Hypertext Transfer Protocol (HTTP) servers were written for UNIX, too, and freely distributed among system administrators who wanted to try out the World Wide Web. CGI was developed as a standard of communication on these systems. In a sense, Perl and HTTP and CGI all became standards for doing Web work (see Figure 1.2).
The beauty of standards is that they usually transcend the platforms on which they originated. The number of non-UNIX Web servers and Web sites on the Internet increases every day. Yet the HTTP-CGI-Perl connection remains the same because it was lifted intact into the newer platforms. UNIX is, in a very large sense, an operating system written by and, most importantly, for programmers. It really was never intended for humans to use easily, which is why so many people have gone to such extraordinary lengths to make UNIX more friendly, with X Windows and various other graphical interfaces. These interfaces require tremendous amounts of processing power, so in many cases system designers have simply given up and relegated bare-bones UNIX to the background, running it on the system server and hanging Macintoshes or other workstations running Windows on the network for users. The beauty of UNIX for those who have taken the time to learn it is in the rich set of software tools that it provides. Unadorned UNIX is like a box of wonderful Swiss Army knives; with any one of them, you can carve any masterpiece your imagination can conjure. Perl is one of the most useful of those Swiss Army knives.
We Owe It All to Larry Wall: A History of PerlLarry Wall is a linguist-turned-programmer who as of this writing was an associate at OReilly & Associates, a technical publishing company. Legend has it that he began working on Perl nearly 10 years ago while attempting a sticky project for Unisys.
Perl actually is an acronym whose most accepted expanded version is Practical Extraction and Report Language, though UNIX wags have come up with many more earthy descriptions, such as Pathologically Eclectic Rubbish Lister. It was derived in large part from sed and awk, jackhammers of the UNIX toolbox for those who understand them, utterly unintelligible command programs for those who dont. After all, what can one say about a program whose most famous error message is awk: bailing out near Line 1? The strengths of sed and awk, and their offspring Perl, lie mainly in their built-in capabilities for processing text through pattern-matching, searching for and replacing phrasesor stringsin entire groups of files, and the use of UNIXs obscure yet extremely powerful regular expressions, which are discussed in full in Skill 5.
The bedrock of UNIX is the C programming languagemost of it is written in Cbut C, in its position at the foundation of the operating system, adheres to the minimalist philosophy of UNIX, which means that you often have to write scads of C code to accomplish relatively simple tasks. A trivial search-and-replace operation on a text file, written in C, requires the programmer to at least scan the file character by character and could easily grow from a simple subroutine into an entire application (see Figure 1.3).
But the same operation can be accomplished in a few lines of Perl code (see Figure 1.4).
UNIX programmers snapped up Perl as a tool of choice almost immediately for doing tasks ranging from quick and dirty to horribly complex. Because you have the ability to call most of the standard UNIX system services from a Perl script, including the internetworking functions, you probably could write an entire operating system in it. It would be very slow, but it would run a computer. To this day, almost every serious UNIX systems programmer works with Perl almost daily. Its just too useful for programmers to ignore.
|
![]() |
Products | Contact Us | About Us | Privacy | Ad Info | Home
Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited. |