Next | Lightweight Databases | 86 |
DB_File actually supports three different file types
tie %hash, 'DB_File', $file, O_CREAT|O_RDWR, 0666, $DB_HASH; tie %hash, 'DB_File', $file, O_CREAT|O_RDWR, 0666, $DB_BTREE; tie @array, 'DB_File', $file, O_CREAT|O_RDWR, 0666, $DB_RECNO;
The default is DB_HASH which we've seen already
DB_RECNO associates a plain text file with an array
But Tie::File may be preferable, for a number of reasons
(See the handout)
DB_BTREE uses a different data structure called a B-tree
Also called a VSAM file by big-iron types
Unlike a hash, it keeps the records in order
For very large databases (1,000,000 records) lookup may be slower than hashes
Next | Copyright © 2003 M. J. Dominus |