The Lucid Developer

Thursday, February 09, 2006

A simple Question Mark

Simple (sim-p&l)


Inflected Form(s): sim·pler /-p(&-)l&r/; sim·plest /-p(&-)l&st/

1 : free from guile : INNOCENT
2 a : lacking in knowledge or expertise b : STUPID; especially : mentally retarded c : not socially or culturally sophisticated : NAIVE; also : CREDULOUS
3 a : SHEER, UNMIXED b : free of secondary complications < style="font-style: italic;">4 : free from elaboration or figuration
5 : not limited or restricted : UNCONDITIONAL
6 : readily understood or performed

There are things in programming that we find easy and there are things in programming we can hit our head against tell we are bleeding. Recently one of my developers had just one of those days.

So let me tell you the tell I like to call "The life of a question mark".

There once was a question mark that lived in a small warm program. He was happy there. Only on rare occasion was he asked to come out and preform some minor function or enforce some small rule. He lived a happy life. For the programmers that used him, used him sparingly. He was forgotten, but happy. Tell one day a new young developer decided to try something he had never tried before. This developer tired as he might but he just couldn't get his code to work as expected. Every time it would return the last result in line and not the first. Oh how this developer tired. Two days of sad and tiring code was written and rewritten. But at last it just wouldn't work. This developer asked the other developers around what he could add to make this cod work. But none knew. But little question mark knew his job well, he could see that the young developer needed just him. But how could he tell him. Then one after noon while looking in a book he found another developer had used the little forgotten question mark. So he figured he would give it a try. And low and behold, our little friend was the answer all along.

Perl snippet:
$var =~ /(.*)/ig; WRONG for this usage
$var =~ /(.*?)/ig; Right