an alternative to "exists" would be to undef all the empty hash keys, just prior to your main processing loop, if that suits.
also looks like your code has outgrown the hard-coded assignment in the hash...so refactoring appropriately would get rid of the need to use "exists".
the hardest line to type correctly is: stty erase ^H