Perl info
 

 

Perl - Practical Extraction and Report Language

Experience Level: < 1 year; comfortable (overlaps with C)

References:  Perl Manual : extremely useful, occasionally funny

Comments:

Perl is a powerful, portable language that makes it simple to do tasks like the log file example found here:
                                
source code   log file

while remaining powerful enough to develop sophisticated applications.

Perl is great for experienced Unix C programmers (well, I got half right) because it mingles desirable language elements from each.  grep, awk and other familiar Unix techniques are mentioned throughout and it is clear that Perl was written to appeal to C programmers.

One advantage is that it (supposedly) manages memory for you.  This is important given that the a server-side application could run thousands of times in an hour and even a small memory leak would be a problem.  On the other hand, you have to rely on the perl processor to garbage-collect properly (earlier versions had some bugs) and over-reliance might mean applications that unnecessarily hog memory for longer periods of time than necessary.

In the advantage / disadvantage category, Perl is designed to appeal to free-spirited programmers.   It provides many different ways to do the same things and does things like default values of some unary functions (ord, int) so you can type ord() or ord($_).  As a programmer, I think this is great - as a manager, I think it stinks.  Specific short-cuts, etc. appear to be quite useful, but I suspect the flexibility leads to longer development times and greater maintenance costs.

One problem with the language is that you can write some perfectly unreadable code - particularly if you take advantage of the "regular expression" capabilities.  I realize these capabilities are probably familiar to UNIX programmers and to people who have worked on parsing projects.  But this code:

                  s/^([^ ]*) *([^ ]*)/$2 $1/; # swap first two words

(taken from the manual above) cannot be easy code to maintain.  (Yes, the corresponding C code would be more tedious to write but a C parser written in a component fashion would be much easier to debug and maintain)