![]() |
![]() |
![]() |
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
![]() |
![]() |
To access the contents, click the chapter and section titles.
Perl CGl Programming: No experience required.
Perl and the World Wide WebPerl has become popular for Web work because in most of its incarnations it is an interpreted language, like the first versions of BASIC, rather than a compiled language, such as C or C++. However, this isnt strictly true, because Perl compilers are available from many sources, just as there are many C interpreters to be had. The essential difference between a compiled and interpreted application is that a compiled program has been translated into the machine language of the computer on which it will run by another program called a compiler. The translated, or compiled, file will run all by itself. An interpreted program, on the other hand, is actually translated and run on the fly by a program called an interpreter. Compiled programs, because they consist of machine-language instructions, generally run faster. But for the same reason, they are not portable from one computer platform to another. Code compiled for a Sun box or a Macintosh wont run on an Intel-based PC because the different processors that power these machines all speak radically different tongues. Your program would have to be recompiled for the target machine before it would work. It may even have to be rewritten. There are no such restrictions on interpreted Perl code. All you need is some version of the Perl interpretercalled perlon the target computer. Perl interpreters have been written for every popular computer platform, from Sun to Alpha to Apple to Intel and more, and with very few exceptions your Perl programs should transport unchanged into every environment. This feature wont sound very important to novice programmers. However, porting C code even between the different flavors of UNIX is an art that not many people have the patience or skill to do full time. It is tedious, difficult, and time-consuming. The capability to develop and test code on one computer and then simply drop it into another, as you can do with Perl, is a boon cherished by all professional programmers. Perl programs are not compiled, which is why we refer to them as scripts. Like shell scripts in UNIX or batch and command files on MS-DOS and Windows NT, Perl programs are just text files that run through an application to process their commands. However, make no mistake about it: Perl programs are just thatprograms, with all the power and versatility the word implies. If youve never written a line of code in your life, Perl will forever spoil you against the more traditional programming languages. If you are a programmer but this is your introduction to Perl, you will find yourself using it more and more as your familiarity with it increases, because it makes things so easy. For the nuts and bolts of Web site processing, administration, and maintenance, tedious system chores that should always be hidden from users, in addition to the creation of truly dynamic Web pages, Perl cant be beat. Building a Perl ScriptNow that you have a little background, youre going to write your first Perl program. Its a simple example that gives you the basic idea of how a Perl script is written and run. All of our subsequent examples will build on this one. Hello World probably seems kind of dumb, but those of us who have been programming for a while have a soft spot for this snippet of code. Its the first programming example given in the monumental C Programming Language by Brian Kernighan and Dennis Ritchie, published in 1976. Many programmers cut their teeth on this work; forgive us, please, if we remember it fondly.
|
![]() |
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. |