Another option would be to use a tied hash. That way the
hash on-disk would be updated in real-time as you manipulated
your hash variable. This may be slower (or faster) depending on the number of
elements in the hash and the number of times you access the hash:
use DB_File;
my %db;
tie (%db,'DB_File','./myhashfile.dat') or die "Can't open hash file\n"
+;
# do stuff with %db here
untie %db;