Straight Perl



Perl is a SemiInterpreted language designed and implemented by LarryWall. He and RandalSchwartz have written a readable book called Programming perl, published by O'Reilly & Associates. These days, the third edition of "Programming Perl" (popularly called the CamelBook) is available, by LarryWall, TomChristiansen, and JonOrwant. Beginners should usually start with the LlamaBook, by RandalSchwartz and TomPhoenix.

I consider perl to be a library of handy routines woven together by a grammar. Some of the routines that have proven useful are ....


Regular Expressions for finding and substituting patterns found in text heading both to and from clients.

Variable Substitutions in literal text. I had a little trouble with perl's variable syntax until I realized how often a variable name appeared within a string.

Block Literal (Here) Text holds and substitutes large passages of HTML.

Flexible and Associative Arrays are data structures that I have trouble programming without. (In modern terminology, Associative Arrays have been renamed Hashes.)

DBM Storage of associative arrays is an idea that sounds good on paper. I've found the implementation buggy and therefore spend many tense hours reconstructing databases. I hear more recent perls are better. (You should have no problems with modern Perl's DBM implementation.)

They say the Berkeley DB 2.0 is worlds better


Perl is actually a more capable object-oriented language than is obvious from the above, particularly when backed by a capable database (MySql, perhaps Oracle or Postgres). Syntax is poor to unreadable, but the effort of overcoming that is repaid by the expressive power. (Well, you can write unreadable code in any language.)

- Fully object-oriented (dynamically bound like Smalltalk not like C++. But you can use Perl for most purposes without using objects, unlike some languages.)

- String interpolation: Anything (other strings, numbers, arrays, even subroutine calls) can be interpolated in the middle of strings.

- Efficiency: rivals Java; perhaps even C.


For programmer efficiency perl is way ahead of java or c. For runtime efficiency, better than java but much slower than c. Still, a well-written Perl program is usually comparable to C, unless you're doing a lot of ?BitTwiddling or other low-level operations.

I've had equivalent programs in C and perl. I could compile and run the C program faster than the perl one. But the perl one was much faster to write.

99 times out of 100 programmer efficiency is more important.


A lot of the overhead in perl is the 'compile' phase. When running under ModPerl this only happens once, and execution speed is often at least an order of magnitude faster. But since compilation happens at a rate of thousands of lines per second, it's usually an insignificant part of the program's overall runtime.

Also, although Perl can have a very unreadable syntax, its flexible grammar can be either used or abused, and written well it's probably actually easier to read than any other language.


A good way to add to Perl's strengths is to use ?PerlModules.

 

Last edited January 29, 2002
Return to WelcomeVisitors