develooper Front page | perl.perl5.porters | Postings from August 2013

deprecate dbmopen/dbmclose

Thread Next
H.Merijn Brand
August 16, 2013 12:45
deprecate dbmopen/dbmclose
Message ID:
dbmopen and dbmclose are there just for backcompat and should not/never
be used:

       [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"). To prevent creation of the database if it doesn't exist,
       you may specify a MODE of 0, and the function will return a false
       value if it can't find an existing database. If your system
       supports only the older DBM functions, you may make only one
       "dbmopen" call 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).

There is a plethora or better alternatives in CORE and on CPAN, and
all docs should refer to tie DB_File instead, naming the alternatives
available in core as inferior possibilities.

As a side note, when dbmopen fails, there is no drop-in replacement.
When DB_File fails, there are a few drop-in replacements available
that might (or might not) work better/faster

H.Merijn Brand   Perl Monger
using perl5.00307 .. 5.19   porting perl5 on HP-UX, AIX, and openSUSE

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About