Learning Perl

I'm learning Perl (for work). A few years ago I had a need for a server-side scripting language and it came down to Perl or PHP. I bought good books on both and after a shot time decided to learn PHP. PHP has served me pretty well, although its poor Unicode support threatened to cause me issues at some point in the future... maybe.

But now I have to learn Perl, and I started with a book co-authored by Perl's creator, Larry Wall. There are many things about Perl to like, and a few to dislike. The really annoying thing about Learning Perl is that it considers all of Perl's worst (in my opinion, of course) features to be a good thing and won't stop evangelising the language.

I'm reading your damn book, stop selling to me.

I can only assume that the authors' desire to constantly proselytise bizarre language features as somehow being good things ("there's more than one way to do it" -- in fact there are way too many ways to do it, and most of them are stupid) constantly rub me up the wrong way. I can accept that Perl supports many, many poorly thought out features for reasons of backwards compatibility, but to argue that they're virtues is just boneheaded.

For example: in PHP a variable is donated by a $ sign, as in $myVariable. I assume this is borrowed from Perl, but none of Perl's more idiotic features came with it. In Perl, there are several kinds of variable, notably $scalars, @arrays, and %hashes. These are denoted by prefix characters as shown. Now, you can have $v[17] and in this case $v[17] is referring to the 18th element of the array @v and has nothing to do with the scalar $v. Confused? You will be.

Perhaps my favorite piece of insanity is this:

"If any list operator (such as print) or any named unary operator (such as chdir) is followed by a left parenthesis as the next token (ignoring whitespace), the operator and its parenthesised arguments are given highest precedence, as if it were a normal function call. The rule is this: If it looks like a function call, it is a function call."

Remember this is a feature, because we've just documented it.

Perl has more ways of denoting strings than there are protons in the observable Universe. How can this possibly be a good thing? In order to understand any fragment of Perl you need to see the entire program.

— Tonio Loewald,