Let's see. I just spent the last hour an a half to two hours debugging a snippet of code I wrote. You see, part of the task at hand was trying to locate the largest section of text within a document based on the location of a certain delimiter. I was effectively doing the following to do so:

my ($largest) = sort { length($b) <=> length($a) } $document =~ m!~\s*([^~]+?)\s*~!g;

The problem I finally discovered after playing with the regex delimiters for way over an hour? It is possible for the delimiters to be placed in such a way that certain sections will be skipped (and therefore the 'longest section' may not be discovered). Which as soon as I figured that out, my decaffeinated brain went "oh", maybe I should use split(). So, the simple fix that immediately fixed all problems I was having:

my ($largest) = sort { length($b) <=> length($a) } split(/~/, $document);

So, this is what happened to me on a day where caffeine failed to enter my bloodstream. My challenge to you? Reply to this node and share with everyone the most frustrating bug or issue you found in your own code that you just could not solve quickly, even though the answer was so obvious you are almost (or completely) embarrassed to admit. Whether it was caused by a caffeineless body or not -- me, I am sticking to the excuse that it is lack of coffee that made me clueless of a simple cure for my code!


In reply to You need more coffee when... by Anonymous Monk

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