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.

About these ads

20 Responses to Why You Should Learn Perl

  1. If you want good OO Perl programming, try Moose/Mouse/MooseX::Declare from CPAN. It even supports roles.

  2. Martin says:

    I agree here. Ruby is new and fun, but it’s just not available by default.

    • ddouthitt says:

      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….)

    • ddouthitt says:

      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…

  3. kace says:

    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.

    • ddouthitt says:

      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.)

    • Are you sure. AFAIK, Perl is installed by default on FreeBSD, it is just all building programs were rewritten from Perl to C.

      • ddouthitt says:

        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.

  4. Have you looked at Moose yet? (Better OO for Perl).

    • ddouthitt says:

      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...]

  5. Court says:

    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.

  6. Craig A. Berry says:

    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.”

    • ddouthitt says:

      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.

  7. Craig A. Berry says:

    By the way, Python is available for OpenVMS:

    http://www.vmspython.org/

    There is a somewhat out-of-date Ruby port here:

    http://www.geocities.jp/vmsruby/en/

    To me, Perl still feels like home. For low-volume discussions of using and maintaining Perl on VMS, send mail to vmsperl-subscribe AT perl DOT org.

  8. Rich says:

    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 )

Google+ photo

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

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 43 other followers

%d bloggers like this: