in reply to Is this a bug or am I insane/stupid/ignorant/etc
Add either use strict; or a -w option (or use warnings if you have 5.6 or greater) to your code. You will see exactly what the problem is.
HTH