If that module doesn't provide an interface to a database (what database do you have in mind?), you will have to roll your own, by extending that module via a subclass or providing methods in that module, preferable via a patch.
If that is not the way for you to go, consider using a different module. The DB_Btree part of DB_File (interface to Berkeley DB) provides multivalue support, and it is pretty fast.
perl -le'print map{pack c,($-++?1:13)+ord}split//,ESEL'
| [reply] [d/l] |
MLDBM?
Regards, Karl
«The Crux of the Biscuit is the Apostrophe»
| [reply] |
There are a number of approaches you can take to store multi-valued hashes to disk. You mention "tie" so i will assume you want to tie a file, i.e. you want to be able to treat the stored hash as a normal hash. The MLDBM module mentioned by karlgoethebier allows you to store multi-level hashes by serializing the values and is very flexible.
If your values always follow the same format (i.e. are not arbitrary) then you can use DB_File or the more advanced BerkeleyDB directly and install your own serialization methods via DBM filters. These filters are invoked transparently every time you read or write a value to the database.
If you can show a sample of your hash structure some other methods can be suggested.
| [reply] |
It sounds like you want to serialize data. Look to YAML, JSON, XML, or any of another list of things to get this done. | [reply] |
If you merely want to *store* data on disk, rather than use a database, you could simply use Data::Dumper to dump a data structure to a file. Then, you want to build a 'hash of arrays' to store multiple key values, like this:
use Data::Dumper;
my %HoA = ();
# crude code to illustrate:
$HoA{'key1'} = ['1', '2', '3'];
$HoA{'key2'} = ['a', 'b'];
# etc.
# Dump it
open($OUTFILE, '>', 'data.dmp');
$Data::Dumper::Indent = 3;
$Data::Dumper::Purity = 1;
printf $OUTFILE Dumper(\%HoA);
close($OUTFILE);
Then, later you can read it back in, and eval it to access the data. | [reply] [d/l] |
I've used DBM::Deep for a pure Perl solution, not requiring any DBMs installed. Also has a 64bit mode to avoid the limit on 4GB filesize for 32-bit.
Probably not your first choice unless you need the pure Perl aspect, but it does work as advertised.
-QM
--
Quantum Mechanics: The dreams stuff is made of
| [reply] |
| [reply] |