Perl for the impatient

A dangerously fast introduction to a dangerously concise language.
Perl
Author

Thadryan

Published

October 4, 2018

Maybe you want something a little more purpose-built than Bash to mine some text and need a refresher. Perhaps you’re in Bioinformatics and want to extract some patterns from DNA (the original weird programming language). Maybe the eccentric, neck-bearded, regex-wizard in your office just retired and you’ve inherited a couple of scripts. Whatever the reason, you need to get (re)acquainted with Perl. I’ve got you covered with a slew of in-context examples of working code.

Perl was originally developed in 1987 (just like yours, truly) by Larry Wall (unlike yours, truly). Before the language took off, he originally set out to automate the processing of text reports on Unix systems. Perl accordingly boasts a lot of support for text processing. Perl espouses the “There’s more than one way to do it” philosophy, often referred to as TMTOWTDI, (pronounced “Tim Toady”), which favors flexibility over standardization (contrast with Python’s “There should be one, obvious way to do it”). The benefits of this approach are intuitive: providing many ways to do things increases the chances that one will “click” for the user, and that the approach used with be just right for the specific task at hand (The drawbacks manifest in difficulty standardizing approaches). This perspective, along with a thriving on-line community & code repository  CPAN (which still exists), brought Perl a great deal of popularity. It simultaneously earned it a reputation as a “Swiss-army chainsaw” or, given its usage in the early days of the web (Perl predates Rails, and even Ruby itself), “the duct tape that holds the internet together”.

Perl also established itself as an influential language in the trend toward high-level programing languages as the cost of programmers started to become more of a burden than the cost of machines. It’s cheaper to pay someone for a few hours of Perl than a few days of C if high-performance execution isn’t a factor, and machines speeding up pushed this calculus in Perl’s favor more and more often. When the Human Genome Project launched in 1990, formalizing the collision of Biology and Computer Science, Perl was the high level language of choice, with Python in its infancy and the whimsical Ruby not yet born. Perl excelled especially in searching for patterns in text, (how DNA is generally represented) helping the match stick. Continuing with the trend of ease-of-use, it’s also easier to convince a skeptical Biologist to put a “$” in front of text and numbers than to, say, use pointers.

Perl’s flexibility will allow you to make yourself a mess (it is, after all, a feature, not a bug according to it’s creator), but a competent programmer can make clean, robust systems with it (almost of as fast as a novice could make ugly, fragile ones in a cleaner language). You’ll also have it at your disposal out-of-the-box on the majority us Unix based systems (including many Macs).

If you’re curious, you can check out the repository here.