associate a DBM database with a DBM array, use the
function, which looks like this:
parameter is a Perl hash. (If this hash already has values, the values are discarded.) This hash becomes connected to the DBM database called
, usually stored on disk as a pair of files called
parameter is a number that controls the
permission bits of the pair of files if the files need to be created. The number is typically specified in octal: the frequently used value of
gives read-only permission to everyone but the owner, who gets read-write permission. If the files already exist, this parameter has no effect. For example:
", 0644); # open
This invocation associates the hash
with the disk files
in the current directory. If the files don't already exist, they are created with a mode of
modified by the current umask.
The return value from the
is true if the database could be opened or created, and false otherwise, just like an
invocation. If you don't want the files created, use a
. For example:
dbmopen(%A,"/etc/xx",undef) || die "cannot open DBM /etc/xx";
In this case, if the files
cannot be opened, the
call returns false, rather than attempting to create the files.
The DBM array stays open throughout the program. When the program terminates, the association is terminated. You can also break the association in a manner similar to closing a filehandle, by using the
returns false if something goes wrong.