DBM Files

One of the simplest ways for your Perl program to remember data in an organized way is through the use of DBM files. A DBM file is a file that's been connected to a Perl hash. To read and write a DBM file, you just manipulate a hash, as you've been doing since Hour 7, "Hashes."

To tie your hash to a DBM file, you use the Perl function dbmopen, as shown here:

dbmopen(hash, filename, mode)

The dbmopen function connects the hash to a DBM file. The filename you supply actually creates two different files on your hard disk: filename.pag and filename.dir. Perl uses these files to store the hash. These files are not text files, and you should not use an editor on them. Also, if one of the files is empty, or seems very large relative to the ...

Get Sams Teach Yourself Perl in 24 Hours now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.