
summer
Deleted
Feb 25, 2000, 2:29 PM
Post #3 of 3
(451 views)
|
|
Re: DBM files and multi dimensional hashes
[In reply to]
|
Can't Post
|
|
MLDBM will certainly do the trick. However it isn't difficult to do it yourself. One way is to use the Storable module: use Storable qw( freeze thaw ) ; # You can then store an arbitrary data structure, say a hash (which can contain hashes, arrays etc.): $data = freeze( \%Hash ) ; # Serialises arbitrary data into a single scalar # You then store the data in the dbm file as normal, e.g.: $dbmhash{$Hash{'KEY'}} = $data ; # And to get the data back: %orig = %{ thaw( $dbmhash{$Hash{'KEY'} ) } ; You could also try the Data: umper module. The most efficient way is likely to be using pack, but that means that your data must be fixed width (except possibly the last field). Advanced Perl Programming has v. good info on this.
|