I found myself responding, earlier today, to a request for a list of reasons for using open document formats (such as, conveniently, the OpenDocument Format) instead of closed, proprietary formats. This was in a non-programming discussion forum, in a thread about things unrelated to programming except in the loosest sense in that office application design came up briefly, and the question to which I responded was distinctly unrelated to programming.

My direct response to this involved posting an ad-hoc Perl script that stored the bullet points of my answer in an array. The script, if run, would randomly (meaning by use of srand and rand()) select one of the points and print it to STDOUT.

Have I been spending too much time thinking about Perl lately? Can you, the Monks, provide me with some more symptoms I should be looking for that I'm afflicted by Too Much Perl?

(I duplicated the code in this weblog entry, which collects most of my commentary in the discussion thread in question in one cohesive essay, in case you're interested in seeing it. It's not remarkable enough to bother reposting here, though. Waste of screen real estate, really.)

print substr("Just another Perl hacker", 0, -2);
- apotheon
CopyWrite Chad Perrin

Replies are listed 'Best First'.
Re: Too Much Perl?
by wazoox (Prior) on Apr 27, 2006 at 11:16 UTC

    if you did one of these lately :

    • watching TV news, you thought perl -pi -e "s/bullshit/truth/g"
    • Lying in your bed at night waiting for sleep, you  for my $sheep ( 1 .. 999) { jump($fence) }
    • in the morning, looking at your wardrobe, you sort @trousers; grep { $red } @tshirts;
      • Then you definetely Perl too much :)

      Oh, come on now. That would never work. If $red was true, you'd get all your tshirts, regardless of colour, while, if false, you'd be overdressed at the beach.

      What I think you meant was: grep { $_->{colour} eq 'red' } @tshirts or, if you're an OO type of guy, grep { $_->colour() eq 'red' } @tshirts.

      However, even that can get a bit messy. I mean, some of us have two, three, or even more, red shirts. Putting them all on at once would look silly, even for a computer geek. (Though, if you're in a workplace filled with perl geeks, you could do that one day - show up wearing all your red shirts, and if anyone asks why you're wearing so many shirts, just tell 'em that you did a grep { $_->has_colour('red') } @tshirts on your closet that morning...). Instead, what you really want is either use List::Utils qw/first/; first { $_->colour() eq 'red' } @tshirts or possibly my @reds = grep { $_->colour() eq 'red' }; $reds[rand @reds] depending on whether you want to be efficient or you prefer some variety.

      Me? Too much perl? Nah ...

        "Never"? This is Perl!

        { package Tie::ColorTest; sub TIESCALAR { my( $pkg, $color ) = @_; bless \$color, $pkg } sub FETCH { my $self = shift; $_->{'color'} eq $$self } } tie my $red, 'Tie::ColorTest' => 'red';
        We're building the house of the future together.
        If you're going to be pedantic, you would have noticed that neither of those statements actually do anything.

        sort and grep are called in void context; it's just frantic early morning thrashing around, before the brain kicks in.

        Presumably, the code later on will end up with the user dressed. Or not, depending on the sort of day it's been.

Re: Too Much Perl?
by TedYoung (Deacon) on Apr 27, 2006 at 14:10 UTC

    If you look at the following code and immediately understand it, then you have been spending way too much time with Perl. I suggest you take a few doses of Java. :-)

    perl -p -e '$\+=$_}{'

    Ted Young

    ($$<<$$=>$$<=>$$<=$$>>$$) always returns 1. :-)

      I guess I'm in the clear, then. I understood what the code did before reading your explanation, but not "immediately", so I should be safe to spend more time with Perl. Whew. What a relief.

      It was the numerical context that hung me up for a few seconds. I kept wondering what good a += operator was to $\ since, like a good little code monkey, I would (almost) never want to add numbers to it from a file for no purpose other than printing them out, and would thus not have fed it numerical input, which didn't make sense to me. Silly me, I was thinking "useful code", not "mild obfu".

      print substr("Just another Perl hacker", 0, -2);
      - apotheon
      CopyWrite Chad Perrin

Re: Too Much Perl?
by GrandFather (Saint) on Apr 27, 2006 at 18:18 UTC

    I find myself wanting to write return if ... in C++ fairly often these days. Is that a symptom?

    Not Perl, but PerlMonks OD leads me to look for the ++ and -- buttons on other web sites, or sometimes even emails! The fact that other (non-programmer) members of the household have come to use ++ from time to time may be another indication.


    DWIM is Perl's answer to Gödel

      Oh, yeah, I do that all the time — think about how to apply ++ and -- operators, or += (though never -= oddly enough), in all kinds of non-Perl contexts. Another one: I often want to use a while loop and regex (or, alternatively, the little Find box in Firefox) to find something I just read a few pages ago when I'm reading a book.

      print substr("Just another Perl hacker", 0, -2);
      - apotheon
      CopyWrite Chad Perrin

Re: Too Much Perl?
by bluto (Curate) on Apr 27, 2006 at 16:47 UTC
    This is like asking fellow asylum patients whether your sanity has failed. What further symptoms do you need to see?

    :-)

      Good point. Maybe I should ask my non-PerlMonk friends.

      Then again, my non-PerlMonk friends would probably consider any amount of use of Perl (by choice) to be insane, so I'm not sure they're a very good source of judgment either. Er. Unless that just indicates something profound about the use of Perl and its relation to insanity, of course.

      print substr("Just another Perl hacker", 0, -2);
      - apotheon
      CopyWrite Chad Perrin

Re: Too Much Perl?
by Happy-the-monk (Canon) on Apr 27, 2006 at 14:26 UTC

    Seems all very sensible to me, apotheon, no reason to worry, do carry on!

    Perl certainly is not like a drug you could ever get too much of =)

    Cheerio, Sören