in reply to writing hash to a file ...is it possible

Q1: Access to a hash of hashes is fast, perhaps your use of the hash of hashes could be speeded up.

Q2: a text based solution could be:
use Data::Dumper; to write out and eval the contents to "reload" what has been written out.