It's strongly recommended btw that you use strictures (use strict; use warnings). Wouldn't have caught this problem, but I can guarantee it will save you hours at some point in the future.
DWIM is Perl's answer to Gödel
Comment on Re: Inverse regexes for input validation