in reply to sanity check

This is not sane. If you were using strict and warnings, Perl would tell you about some of the things that are wrong with your code. Other parts of your code look like you just made up something and expect Perl to make sense of it. That's not how programming works.