Because Perl definitely isn't dead.
Random header image... Refresh for more!

Top 10 Perl lovelies

As the title suggests, the top ten things that only Perl does. I reckon I’d change this list on a pretty much daily basis, but here goes:

  1. $| = 1; Lovely little nuances like this make it so interesting. For anyone interested, who doesn’t already know this stops the screen buffer from writing out only on a new line (or when it’s full) and printing out one character as a time. Useful for those … status updates I’m fond of.
  2. $z =$a ? $c : $d; Ternary operators, lovely pieces of code although I have pretty much ceased using them recently in favour of more readable code. This example evaluates to if($a) {$z = $c} else {$z = $d};
  3. CPAN CPAN stands for Comprehensive Perl Archive Network. It’s the first stop for Perl functionality. If you need to write something, you can pretty much guarantee that someone already has. Check out CPAN and see what’s available. As it’s all open source everything on it has the advantage of being reviewed by the community at large.
  4. Test::More Test::More is a fairly basic testing module that can do various things. It plugs in nicely with the Prove utility to provide the essentials for testing your code.
  5. DBIx::Class I have to admit, when I first started using DBIC I wasn’t the biggest of fans. In my opinion it still doesn’t generate particularly nice SQL, however it does make development a breeze. Define your tables, define your relationships and let it do all the work for you. Just remember to make sure you write plenty of tests to make sure you don’t get bitten by any unexpected behaviour!
  6. Portability Perl interpreters exist for pretty much any OS you can think of. With only a hand full of exceptions, practically any code can be written and run on any architecture you choose!
  7. Mod Perl Mod Perl was the best thing ever for a web developer. I mean I could just load all the code into memory with Apache. Pool my DB connections etc etc and watch the systems simply fly. Having said that it’s only on the list because I had such a love for it. New and improved lovelies have come along now…..
  8. Fast CGI Fast CGI is even better than Mod Perl! That takes some doing, but being as I primarily work on large Catalyst apps it wins hands down for one simple reason. I can restart the app without having to restart the whole web server and hence all the other apps. The Catalyst apps we use at work take about 5 mins to restart with Mod Perl, with Fast CGI it’s about 30 seconds. Fast CGI also offers all the benefits of Mod Perl that I use and probably some more.
  9. Template Toolkit TT is my current templating system of choice. It’s been my primary choice for a few years now having used a few of the alternatives in years gone by. Having said that, I’m told that Mason has come on a long way in recent years and intend to do more investigation at some point!
  10. TMTOWTDI There’s more than one way to do it…. It’s been a sort of motto of Perl for years and it’s as true today as it was the day it was first coined. Ask any group of Perl developers for a function to do pretty much anything and you are likely to get wildly different results. This variance and artistry of code means that there is always a faster/more readable/smaller/lower complexity/more poetic way of doing anything in Perl. That makes it an art in its own right!

That’s it! They aren’t in any particular order and probably not that definitive. I’m sure I’ll think of something I missed as soon as I hit submit.

1 comment

1 lee doolan { 10.22.08 at 9:35 pm }

I cannot see why people regard the ternary operator as ‘not readable’. I think that it is readable and concise. I tend to frown on coders who use if … then … else when they could have used ternary.

Leave a Comment