I blame a lack of sleep and caffeine.
This morning I was convinced that undef returned true if its parameter was defined. I don't have any reason or excuse, but I stared at that section of code for far too long trying to figure out why it wasn't working. Falling back to RTFM it was easy to see my mistake.
Sigh.