: Can someone tell me just what Perl ***is***? I've seen lots of talk about it,
: none of which gives the slightest idea what it actually is. Just like that
: Satanic Verses book -- lots of news coverage, but no one actually gives a clue
: what it's about or why certain groups are outraged by it.
Certain groups outraged by perl? I hope not. Gulp...
Anyway, you asked for it. I could go on all day about what perl is and bore
you to tears. I'll attempt to restrain myself.
Perl is a language that partially sacrifices one aspect of "Unix philosopy"
(namely the toolbox approach) in order to collect many other aspects of "Unix
philosophy" into one spot. Perl is a language for C programmers who want
to do shellish, sedish and awkish things without having to write a spaghetti
bowl full of pipes and obscure Unix commands. The toolbox approach has its
place, but sometimes the solution in Perl is more readable than the
corresponding solution in shell. I like it, but then, I'm just a little
biased on that subject. :-)
For more info, here's the hype paragraph from perl 3.0 (alpha). (Note
that 3.0 isn't released yet--2.0 didn't handle binary data or dbm files.)
Perl is a interpreted language optimized for scanning arbi-
trary text files, extracting information from those text
files, and printing reports based on that information. It's
also a good language for many system management tasks. The
language is intended to be practical (easy to use, effi-
cient, complete) rather than beautiful (tiny, elegant,
minimal). It combines (in the author's opinion, anyway)
some of the best features of C, sed, awk, and sh, so people
familiar with those languages should have little difficulty
with it. (Language historians will also note some vestiges
of csh, Pascal, and even BASIC-PLUS.) Expression syntax
corresponds quite closely to C expression syntax. Unlike
most Unix utilities, perl does not arbitrarily limit the
size of your data--if you've got the memory, perl can slurp
in your whole file as a single string. And the hash tables
used by associative arrays grow as necessary to prevent
degraded performance. Perl uses sophisticated pattern
matching techniques to scan large amounts of data very
quickly. Although optimized for scanning text, perl can
also deal with binary data, and can make dbm files look like
associative arrays (where dbm is available). Setuid perl
scripts are safer than C programs through a dataflow tracing
mechanism which prevents many stupid security holes. If you
have a problem that would ordinarily use sed or awk or sh,
but it exceeds their capabilities or must run a little fas-
ter, and you don't want to write the silly thing in C, then
perl may be for you. There are also translators to turn
your sed and awk scripts into perl scripts.
Perl 2.0 was distributed in comp.sources.unix. You can also ftp it
from jpl-devvax.jpl.nasa.gov (184.108.40.206) at patchlevel 18. Version 3.0
will be available Real Soon Now, depending on how the Magellan shuttle launch
(and my little part in it) goes.
Well, that's enough for now, I think. Oh, to answer the question in the
original article, one place to get sample perl scripts is in the perl
distribution itself. Look in the eg subdirectory. Also, the regression
tests are all written in perl. So is the sed-to-perl translator.