On Fri, Oct 22, 2004 at 02:32:09AM +0200, Louis Pouzin wrote: > I have a data base of IP/domain names that I maintain as plain text > files. The size is only a few hundred K octets. > > I use a hash (of of hashes) for various searches. Building the whole hash > takes a few seconds. > > As the ratio of updates/searches is in the order of 1/15, I'd like to > restore the whole hash from a file, in view of shortening response time > when doing searches. > > Is there some routine/package such as "save/restore %H,FileHandle" ?
Modules such as Storable, Data::Dumper, or YAML allow you to save a Perl data structure to a file and read it back in. There are advantages and disadvantages to each one. Another option is to save your hash in a DBM, which is basically a way of storing and accessing a hash on disk, without needing to have it in memory. For a hash of hashes, you would need to use MLDBM (the ML is for multiple level). Ronald