Eschew Obfuscation!

Sometimes Perl gets a bit of a bad rap for being a language in which it is trivially simple to write utterly unmaintainable code.

Today Slashdot even reviewed a book, Perl Medic, aimed at helping people to demystify the inner workings of their colleagues’ incomprehensible apparent line noise, posing as a supposedly high-level language.

I personally think Perl’s a great tool for getting the simple things done simply, and getting even the most complex of tasks done without too much in the way of hassle. Whatever you want to do, there is almost certainly a module freely available on CPAN to help you in doing so.

And yes, I generally make sure that my code uses both the strict and warnings pragmas, and try to use sane variable and sub naming schemes in anything more than a couple of lines long.

But it’s still always a bonus to be able to use such a behemoth of mind-bleedingly insane code as the gorgeous Mail::RFC822::Address module, as I did today. Yes, there are perhaps more reasonable ways to verify the integrity of a supplied email address, but I’m afraid I just rather like the idea of passing my input through this.

3 thoughts on “Eschew Obfuscation!

  1. Yuck. Never bothered learning Python, since Perl served me so well.

    Here’s my Perl solution to #2, (hopefully everyone can cope with #1 themselves) but I think I’ll have to tackle the rest later.

    #!/usr/bin/perl
    use strict; use warnings;
    my $a = qq{g fmnc wms bgblr rpylqjyrc gr zw fylb. rfyrq ufyr amknsrcpq ypc dmp. bmgle gr gl zw fylb gq glcddgagclr ylb rfyr'q ufw rfgq rcvr gq qm jmle. sqgle qrpgle.kyicrpylq() gq pcamkkclbcb. lmu ynnjw ml rfc spj.
    };
    for (split(//,$a))
    {
    if((ord($_)>=97)&&(ord($_)122);
    print chr($b);
    }
    else
    {
    print $_;
    }
    }

  2. And having just remember about tr//, I’ve simplified it to this:

    #!/usr/bin/perl
    use strict; use warnings;
    my $a = "g fmnc wms bgblr rpylqjyrc gr zw fylb. rfyrq ufyr amknsrcpq ypc dmp. bmgle gr gl zw fylb gq glcddgagclr ylb rfyr'q ufw rfgq rcvr gq qm jmle. sqgle qrpgle.kyicrpylq() gq pcamkkclbcb. lmu ynnjw ml rfc spj.";
    $a =~ tr/[abcdefghijklmnopqrstuvwxyz]/[cdefghijklmnopqrstuvwxyzab]/;
    print $a;

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">