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:
$user = ~ s/^\s+|\s+$//gs;
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?
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. :)
|
|---|