Perl and Other Improbables

Learning Perl‘Perl’ And Other Improbables
first published in the PAUG Newsletter, May 2000

Perl is a server-side scripting language created by Larry Wall, a living legend in programming circles and, particularly, in CGI and UNIX circles.

‘Perl’ stands for “Practical Extraction and Report Language”. For reasons never made clear, the acronym PERL is not in all-upper case, and remains “Perl” to this day. But we’ll get back to that.

Perl derives its heritage from the original C programming language (parent language of C++), and from UNIX Shell programming. UNIX is an OS written in C. But we’ll get back to all that, too.

First of all, then, why would we be interested in Perl, instead of, say, Mesopotamian clay tile irrigation systems, or Maxwell’s Equations and the Fourier Transforms? Assuming anybody would be interested in a subject with universal application and appeal, the plain truth unravels this way: there’s no way to varnish this into one of those subjects. But Perl is one of the basic “glue” languages that make everything else in our personal computing world stick together.

Assuming we’re not a professional programmer, scientist, Internet Service Provider or UNIX hacker, only those of us who frequent the Internet might care. Of these, only those who maintain a web site might care. And, of these, only those of us who upload our web pages to an independent provider (not AOL or EarthLink) would walk that mile for the Llama. For most of us, Perl is, well, improbable.

But don’t thank me now! This century is awash in buzzwords like we’ve used here. They have important meaning to someone: some folks are getting rich off these buzzwords, and it’s our money. Where is it being spent?

Perl was created to bridge the huge gap from the cryptic lists, arrays and memory dumps of the typical computer output, over to our human-readable reports, formatting, styling and displays. “Extraction and Report Language” means you can produce elegant reporting with Perl: graphics, memo-style text, tab-delimited text (spreadsheets), database files of any sort.

As a true programming language, you can output Perl to the screen, printer or anywhere that one to ten million readers might congregate to view it. As a true programming language, Perl is infinitely “extensible” – I first thought that’s what the “e” stood for. You can write your own functions and subroutines to describe color and sound management, collapsible lists, or Mesopotamian clay irrigation tiling. Actually, most of that’s already been done for you.

This means Perl was and is the first “natural” language for handling all these different possible kinds of output problems on the “server side” — on your web host’s server machine. Many of us have hand-crafted HTML tables into columns and rows to format or display our pages better. But you can’t write an HTML web page to calculate the values that need to be in those cells.

Even if you could, you probably wouldn’t want all those calculations performed on the web viewer’s personal computer. Surfers just want answers, and would be furious if their machine was tied up every time they wanted to look at your web page. Perl, like Java (and, to a lesser extent, Javascript) form part of what they call “CGI”, or “common gateway interface”. Oversimplified, this provides a way for the outside world to access and even exploit the computing power of the server. (Finding and illegally exploiting loopholes in that interface is part of the motivation of malicious hackers).

Perl was and is the first practical answer to questions like: how do we deliver any part of this book, or even this entire book, to a web page?

For the home user with a web page and CGI connection, Perl is one way to provide elegant but simple features like counters, survey forms, mail-to forms, guest registers, and (ugh!) even flashing banners and ads. The home user just adds a short line to their HTML which calls the program, which does the work and delivers the output to the web page. Although advisable, it is not even necessary to know the HTML markup to produce these forms and counters, since this is already “canned” in the server-side programs.

Java is a much newer language (its parent is mostly the god-like C++) which also executes on the server side, also saving incalculable work and time. Javascript is mostly a “client-side” derivative, running on the user machine via little disposable programs called applets. Modern browsers automatically install a Java engine on your machine with the supporting superstructure required to run the applets. From the user point of view, we notice very little difference.

We read much of the above jargon in the newspapers and computer magazines almost every day. Programming in Perl or Java carries a steep learning curve, and it isn’t for most of us, but it doesn’t cost a cent to know what the terms mean and how they relate to everyday computing. And, when you think about it, our personal computing environment makes more sense, and is easier to learn, when we understand better how all the parts fit together. Thanks for sticking with this!

Next month: Mesopotamian clay tile irrigations systems. Or C++. Your call.

©Alex Forbes 05-05-2000

Thanks to Ben C. for writing on 6/15/2005 with this correction:

Just thought I should point out that there is an error on the “Perl Improbables” page.

“Java is a much newer language (its parent is mostly the god-like C++) which also executes on the server side, also saving incalculable work and time. Javascript is mostly a “client-side” derivative, running on the user machine via little disposable programs called applets.”

The above paragraph makes the mistake of associating Javascript with the Java programming language. Applets are not written in Javascript, but Java. Both Java and Javascript can be either server-side or client side. Most importantly, Java and Javascript have absolutely nothing to do with each other.

292 total views, 1 views today