Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- PERL 4.0 Reference Guide - Norton Guide http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]

     dbmopen(ASSOC,DBNAME,MODE)

             This binds a dbm or  ndbm  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 sup-
             ports the older dbm functions, you may only have one
             dbmopen in your program.  If your system has neither
             dbm nor  ndbm,  calling  dbmopen  produces  a  fatal
             error.  (MS-DOS users: the MS-DOS port uses Gnu-dbm,
             which supports multiple files.)

             Values assigned to the associative  array  prior  to
             the  dbmopen  are  lost.  A certain number of values
             from the dbm file are cached in memory.  By  default
             this number is 64, but you can increase it by preal-
             locating that number of garbage entries in the asso-
             ciative array before the dbmopen.  You can flush the
             cache if necessary with the reset command.

             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:

                  # 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: dbmclose

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson