Syntactic Confectionery Delight | |
PerlMonks |
How to introduce a frustrating bug with a single whitespaceby radiantmatrix (Parson) |
on Dec 24, 2007 at 20:00 UTC ( [id://658921]=perlmeditation: print w/replies, xml ) | Need Help?? |
There's probably more than one way to accomplish the goal in the title -- and I'd love to hear stories about it, if only because it'd make me feel better. I had the following, very simple line of code:
The intention, of course, was to trim white space from the beginning and end of a user name previously parsed from a record. Instead, though, $user ended up containing a large and random-seeming number. Spot the bug? <Reveal this spoiler or all in this thread>
Stepping through the code with the debugger found the line where the oddness was occurring, but it seemed like inexplicable madness (for something like 10 minutes) until I noticed that one extra space. Man, do I feel stupid! The lesson? I probably should have used Text::Trim. :)
<–radiant.matrix–>
Ramblings and references The Code that can be seen is not the true Code I haven't found a problem yet that can't be solved by a well-placed trebuchet
Back to
Meditations
|
|