Why You Should Learn Perl

Previously I spoke on why one should learn vi (summary: learn vi because it’s on every UNIX and Linux system you’ll install…). Well, why should one learn Perl?

Because it’s only every UNIX and Linux system you’ll install…. and on OpenVMS… and available for Windows, too.

Unlike vi, I’m not as big a fan of Perl as I once was: having been interested in (and a fan of) object-oriented programming (OOP) for years – it only took Ruby little time to dislodge me from my interest in Perl (that would have been just prior to Perl 5).

Yet, this does not matter: Ruby is nice, but not ubiquitous. In particular, making Ruby run on HP-UX has proven to be extremely difficult in recent years – and it is not loaded by default in any case. I don’t know of any UNIX that installs Ruby as part of the base package (or that makes it available at all).

Learning Perl is not as hard as it may seem: since it is ubiquitous, there are many excellent books from which to learn Perl – and excellent references as well:

I have all of these, and find all of them to be useful. In my progression of learning Perl (or relearning it…) I find that Effective Perl Programming is fantastic. Specifically, presents a series of items (or tips) then shows you how to use and understand the tip in detail. I recommend this book fully.

Don’t neglect Perl, as it is everywhere, unlike any other language (including Korn shell!). If all you write is Korn shell, then your program will be unusable in any environment that does not provide ksh (think Linux and FreeBSD and OpenVMS for three). It’s true: ksh is not installed on Linux by default: bash is – and FreeBSD uses the C shell. However, all three environments provide Perl.

20 thoughts on “Why You Should Learn Perl”

    1. I tried (briefly) to get Moose started up. After watching the dizzying array of requirements fly by in my attempt to use CPAN, I gave it up. Does it *really* need all that?

      Ruby has OOP built-in and Itcl is no more than an add-on package. Is that much overhead really necessary?

    1. Which is a real shame!

      It was Ruby that caused me to learn how to add my own RPMs to a Red Hat install disk! (Hooboy, I just dated myself….)

    2. I should make a point here: Ruby is *not* new but is going on 10 or 15 years by now. It’s not new.

      I learned Ruby on HP-UX 10.20 with Ruby 1.4. How things have changed…

  1. I don’t know what the issue might be with Ruby and HP-UX, but I know Ruby is easily available on FreeBSD and most linux and unix systems. (And, a minor, even pedantic, point: Perl is not in the base system of FreeBSD any longer. (But, it’s a dependency for so many things, that’s it’s hard to find a running FreeBSD without it!))

    I don’t write Ruby, but have heard good things about it. But, I’m mainly commenting to heartily recommend Python. It’s very nearly ubiquitous these days. Even ships in the OSX base. I hope you’ll try it. It’s OO and may turn out to be easier to run on HP-UX. Who knows. Good luck.

    1. Python doesn’t come on HP-UX as part of the install – nor is it available on OpenVMS as far as I know.

      I’m not a fan of Python either. For instance, I can’t reconcile while having significant whitespace is a plus in Python and a negative in Make – and I’d rather use Make.

      The other thing I notice about Python is that all of the memory hogging programs I know about are written in Python. I can run apt-get where yum would bring a host to its knees for example; likewise, I can’t install Linux on a system where it could run but for the fact that Anaconda runs out of memory and crashes. (Both Yum and Anaconda are written in Python.)

      1. Ruby is also very nearly installed “by default” (so to speak) on FreeBSD: it is used by the portupgrade tool to manage the ports system.

    1. Can’t say I have. Aside from Ruby, it was the “bolted-on” OOP that turned me off of Perl 5.

      Now that I’ve “come back” (so to speak) a nice OOP would be a delight to use.

      [I should add: the two reasons I came back: 1) Ruby isn’t available on HP-UX 11i v3; 2) Ruby isn’t available for OpenVMS. Sigh. One day…]

  2. I love perl. I have tried other languages, but always find myself going back to perl. The number one reason I keep coming back is the number and variety of packages available. In fact i just used the Image::Magick package the other day to change the compression type on 1000’s of tiff images.

    Perl is my panacea.

  3. Having OOP “bolted on” may seem like a disadvantage to some, but not having to use it when you don’t need it is actually one of the nice things about Perl. You can do one-liners that replace anything you would do with awk or sed, write small utility programs, or massive, modern OO frameworks, or anything in between.

    This makes for a very natural development cycle as your program evolves and changes in response to whatever real-world problem it solves. You add the features you need when you need them. When you start needing to reuse bits of your program, then it’s time to make a package out of it. If you find that you have more than one or two global variables and your program is getting longer and what you thought was a little once-off script is about to become the cornerstone of some critical production job, then you add the OO features you need (and there are many choices for how to do that).

    Working this way probably violates a bunch of high falutin design principles, but it happens to be a very effective way to get work done in the real world. The “P” in Perl stands for “practical.”

    1. Sure the “P” stands for “practical” – but the “r” stands for “rubbish” 🙂

      You make a mistake at mentioning sed: I love sed…. and you would be amazed at what it can do.

      As for OOP, Ruby is a complete object-oriented environment and it can do the same “one-liners” that Perl can (if you don’t write them in sed first……..) I’ve been fascinated and interested in OOP since before Perl existed – so when Ruby came along it was like a dream come true.

  4. As a tech person with no knowledge of programming I have taken it upon myself to first learn the core fundamentals of programming first. Been using Simon cozens Beginning perl book and the format is great for beginners

    Along with that I have been using resources to learn python as well. MIT offers free online courses on python to teach the fundamentals of programming, along with python.

    Any language seems to come down to personal choice or professional needs. Which ever one gets the job done should be the preferred choice. As long as you have the foundation of programming, you can use anything necessary.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: