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 simply manipulate a hash, just as you've been doing since Hour 7, “Hashes.”

To tie your hash to a DBM file, 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 one or two different files on your hard disk with names that are a variation on filename: filename.pag, filename.dir, or filename.db. Perl uses these files to store the hash. These files are not text files, and you should not attempt to use an editor ...

Get SAMS Teach Yourself Perl in 24 Hours THIRD EDITION 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.