Modules are available to tie various DBM files to hashes.
Use AnyDBM_File.pm to inherit from the appropriate module.
Example:
use Fcntl;
use AnyDBM_File;
tie (%hash, 'AnyDBM_File', 'db', O_RDWR|O_CREAT, 0640)
or die "db: $!\n";
$hash{'key1'} = 'var1';
$hash{'key2'} = 'var2';
$hash{'key3'} = 'var3';
untie %hash;