AcornSearch - Acorn and RISC OS information searching
RISC OS Search
containing
"Nutty quip goes here!"
Home  |  About  |  Filebase Archive  |  StrongHelp Manuals  |  Newsgroups  |  Module Database
dbmopen ASSOC,DBNAME,MODE

[This function has been superseded by the tie() function.]

This binds a dbm(3) or ndbm(3) file to an associative array.  ASSOC is the
name of the associative array.  (Unlike normal open, the first argument
is NOT a filehandle, even though it looks like one).  DBNAME is the
name of the database (without the .dir or .pag extension).  If the
database does not exist, it is created with protection specified by
MODE (as modified by the umask()).  If your system only supports the
older DBM functions, you may perform only one dbmopen() in your program.
If your system has neither DBM nor ndbm, calling dbmopen() produces a
fatal error.

If you don't have write access to the DBM file, you can only read
associative array variables, not set them.  If you want to test whether
you can write, either use file tests or try setting a dummy array entry
inside an eval(), which will trap the error.

Note that functions such as keys() and values() may return huge array
values when used on large DBM files.  You may prefer to use the each()
function to iterate over large DBM files.  Example:

dbmopen(%HIST,'/usr/lib/news/history',0666);
while (($key,$val) = each %HIST) {
print $key, ' = ', unpack('L',$val), "\n";
}
dbmclose(%HIST);


[sh-index] Back to list of manuals