Read the following as a good natured meditation on the sociology of the Monastery:

Here is the scenario:

Anonymous Monk posts a question, such as:

"How do I empty out a hash?"

Then the answers roll in. There are subtile differences, and some of the answers are entirely valid approaches depending on how the context of the question is intrepreted. Others are rubbish. Please remember, I didn't invent these, I just dug them up with the Perlmonks search engine:

As merlyn poined out, the third solution isn't a solution at all. But eventually things get a little over the top in the context of such a simple question:

How about this example:

Newbie asks: How do I find the index of the last element of an array?

That last example doesn't even do what the question asked, but rather yields the last element, not the index of the last element.

These are very simple examples. They are, however real examples found within real nodes here in the monastery. I chose simple one-liner type examples only to illustrate the point concisely. But I am sure that most of us can think of times when a very simple question, asked in a simple and reasonably well-defined way, resulted in many, many solutions being proposed. Thought provoking answers are good. But most of us can also think of times when many of the proposed solutions ventured down that road of each one wackier and farther from "the Perl way" than its predecessor.

Of course, "The Perl Way" is that there is more than one way to do it. But do we really need to consider the possibility of using, my $len = do { split //, $string; my $counter; $counter++ foreach @_; $counter }; to determine the length of a string just because it's in the spirit of "Another Way To Do It"?

I am all for the diversity of technique that Perl provides the opportunity to explore. But sometimes I find myself wondering, was this response posted because it's a good way to do something, or because the poster found a hot thread and wanted a shot at a few more experience points?

My favorite example of common sense prevailing is the one of merlyn pulling back in the reins when the simple question was asked, "How do I concatenate two strings?". Several answers came in: join "", @strings;, and $string = "this" . "that";, and even  $string = "$first$second"; Then along comes a class act with the best answer of all: "   ."

Friday golf, obfus, and abused regexp engines can be fun mindbenders. However, it seems like many of the zanier solutions to a simple problem are proposed in what seems to be all seriousness, and it's those sorts of posts that lead me to wonder if this is an XP chase or just plain bad style.

I'm curious what others feel regarding this issue. I'm not looking for "a solution". It's not even a situation in need of a solution. In fact it's not even a situation. It just seems to be human nature to try to one-up the last guy, and often that leads down a chaotic road.

Many will assert that all these examples of many ways to do the same thing are good for the thought process. I don't disagree. But it strikes me as an interesting thing to mull over.

What is the point to this post? My objective is simply to express a meditation. ;)


Dave


"If I had my life to do over again, I'd be a plumber." -- Albert Einstein

In reply to TIMTOWTDI doesn't mean invent an outlandish approach (usually) by davido

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.