Don't EVER put a variable name in a variable.
I created hash tables for each of these instances and then hit a snag. Instead of duplicating the code for each hash table I thought I would just have the one piece of code with the relevant hash table name as a variable.
Have a single subroutine which takes a reference to the appropriate hash as one of its parameters.
Incidentally, you really should reduce the code needed to demonstrate your problem to the bare minimum. You posted too much code, and I don't have the patience to read it.