PERLFUNC: dbmopen - create binding on a tied dbm file 
Author Message
 PERLFUNC: dbmopen - create binding on a tied dbm file

(This excerpt is from the perlfunc manpage, part of the standard set of
documentation included with every valid Perl distribution--like the one on
your own system.  See also http://www.*-*-*.com/
or http://www.*-*-*.com/
if your negligent system adminstrator has been remiss in his duties.)

NAME
    dbmopen - create binding on a tied dbm file

SYNOPSIS
    dbmopen HASH,DBNAME,MASK

DESCRIPTION
    [This function has been largely superseded by the `tie' function.]

    This binds a dbm(3), ndbm(3), sdbm(3), gdbm(3), or Berkeley DB file
    to a hash. HASH is the name of the hash. (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 any). If the database does not exist, it is created
    with protection specified by MASK (as modified by the `umask'). If
    your system supports only the older DBM functions, you may perform
    only one `dbmopen' in your program. In older versions of Perl, if
    your system had neither DBM nor ndbm, calling `dbmopen' produced a
    fatal error; it now falls back to sdbm(3).

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

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

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

    See also the AnyDBM_File manpage for a more general description of
    the pros and cons of the various dbm approaches, as well as the
    DB_File manpage for a particularly rich implementation.

    You can control which DBM library you use by loading that library
    before you call dbmopen():

        use DB_File;
        dbmopen(%NS_Hist, "$ENV{HOME}/.netscape/history.db")
            or die "Can't open netscape history file: $!";

--
_doprnt(pat, args, &fakebuf); /* what a kludge */
    --Larry Wall, from util.c in the v5.0 perl distribution



Mon, 10 Dec 2001 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. PERLFUNC: dbmopen - create binding on a tied dbm file

2. PERLFUNC: dbmclose - breaks binding on a tied dbm file

3. PERLFUNC: dbmclose - breaks binding on a tied dbm file

4. Creating DBM files with Tie

5. (Readable) tie/untie use with dbm files, pattern match in dbm file fails on certain keys

6. tie/untie use with dbm files, pattern match in dbm file fails on certain keys

7. PERLFUNC: untie - break a tie binding to a variable

8. PERLFUNC: tie - bind a variable to an object class

9. PERLFUNC: untie - break a tie binding to a variable

10. PERLFUNC: tie - bind a variable to an object class

11. PERLFUNC: bind - binds an address to a socket

12. PERLFUNC: bind - binds an address to a socket

 

 
Powered by phpBB® Forum Software