Umm... you won't be. The only keys in %hash1 that are ever checked are values that exist in @ary. I'm assuming that @ary is the list of allowable parameters. That would mean that any values in %hash1 that didn't exist in @ary would never make it into %hash2. And, likewise, any values in @ary that don't exist in %hash1 don't make it into %hash2.