Perl was one of the first languages that I ever learned and actually truly did things with; it was the first language I ever wrote a nontrivial program in (a DES implementation that I have unfortunately lost the source code to, or else I would post it). The first language I ever wrote a program in was something I don’t even remember in BASIC; I seem to have blocked all memory of it from my memory, probably for the better. So I have a bit of a soft spot for the language, and so I still have some of my bad habits; since I didn’t use strict or -w, my code would likely be full of uninitialized variables and barewords. It’s a bad habit, and to this day I still have to be reminded occasionally that other languages, such as Python, do require variables to be declared.
But Perl is old now, and I’ve mostly moved on to other languages, like Python. I like the object-orientation, the support for functional paradigms and other nice things like list comprehensions and lambda functions. I like not having to sigil all of my variables with $ or @ or %, I like being able to supply keyword arguments to my functions so that I don’t have to remember which weird order I decided to use, I like the sheer amount of fun things that you can do with object orientation combined with reflection, metaprogramming, and everything being a first-class object. And yet, I still think it’ll stick around for a while.
Why do I say that? Simple. I was talking with someone who had left in the middle of an online IRC-based role-playing game, and they had asked for chatlogs of what had happened after they left. I had them, since I run weechat in tmux (like irssi in screen, but better!) and so am in every IRC channel I’m in 24/7. But the question was: how could I pull out just the lines that were said when he left? And the answer was Perl. It turns out that the .. operator, which in a for loop or other situations where a list is expected produces a range (so (1..9) as a list produces the list (1,2,3,4,5,6,7,8,9)), does something completely different in a scalar context, like in the conditional of an if statement. Take the statement print if (/Person.*has quit/ .. /Person.*has joined/). Each time this statement is run, the conditional will evaluate to false, until the left-hand side evaluates to true. Then it’ll start evaluating to true, until the right-hand side evaluates to false, and then it’ll stop being true (but it’ll still be true until it’s evaluated again!), etc., etc. So if this is in an implicit while loop running through the lines of a file, it’ll start printing when it sees a line saying Person has quit, including that line, then stop when they rejoin, but still print that line, and then it’ll keep going until it sees another quit line, etc. And the best part is, if you call perl with -n, you automatically get a while loop that assigns the current line of the file it’s reading from to $_, the implicit variable in the matching and print.
If I wanted to do that in something like Python, I’d have to manually set up the read loop, write a function to trawl through, build up regexp objects to match on, etc. And that’s fine for a piece of code I intend to maintain. But for a quick one-line script like this? Too much effort. All I need is perl -ne.

Kevin Riggle
/ May 20, 2010It wasn’t clear to me that you were saying this, but I want to point out to you in case you weren’t aware that all of these statements could also be true of Perl:
Patrick
/ May 21, 2010I know that Perl is capable of doing all these things, but my point is that (at least in my opinion) Python does them better than Perl does. Perl is a procedural language more than it is an object-oriented one, I think, and while you can certainly do OO stuff, you can’t do it with the same ease that Python lets you.
Geoffrey
/ May 23, 2010awk ‘/Person.*has quit/ {n=1} /Person.*has joined/ {n=0} n==1 {print}’
I’m not entirely sure why I know awk, but I now find it easier than Perl for these sorts of one-liners. And for all I know there’s a better way to do that in awk, but this works.
Perl was basically intended to be awk and C at the same time. It succeeded amazingly, but I think there’s room for a better awk.
Hercynium
/ May 24, 2010I concur with your primary point – Perl historically has a plethora of features that make many one-off tasks simple and concise. However, I would like to add that there is another, much more compelling reason that Perl (meaning Perl 5, of course) will be around for many many years to come:
Perl is an exceedingly malleable language. In the past few years, development has received a shot in the arm, and not only in the core and interpreter, but through CPAN extensions like Devel::Declare and Moose, and the ecosystem flourishing because of what those tools enable.
I dare say, much like Lisp, Perl is not just a language, but also raw building materials… and there is continual work by its community adding new constructs and syntax and capabilities, lovingly stolen from many other languages like Python, Haskell, Ruby, and even Perl 6.
In short, Perl 5 will stick around and remain useful as long as the community can mold it to their wants and needs – and I don’t think there is any end to that in sight!