Modules

  • ABCDE
  • FGHIL
  • MNOPS
  • TUX

Tools

AnyDBM_File

Perl 5 version 8.8 documentation
Recently read

AnyDBM_File

NAME

AnyDBM_File - provide framework for multiple DBMs

NDBM_File, DB_File, GDBM_File, SDBM_File, ODBM_File - various DBM implementations

SYNOPSIS

  1. use AnyDBM_File;

DESCRIPTION

This module is a "pure virtual base class"--it has nothing of its own. It's just there to inherit from one of the various DBM packages. It prefers ndbm for compatibility reasons with Perl 4, then Berkeley DB (See DB_File), GDBM, SDBM (which is always there--it comes with Perl), and finally ODBM. This way old programs that used to use NDBM via dbmopen() can still do so, but new ones can reorder @ISA:

  1. BEGIN { @AnyDBM_File::ISA = qw(DB_File GDBM_File NDBM_File) }
  2. use AnyDBM_File;

Having multiple DBM implementations makes it trivial to copy database formats:

  1. use POSIX; use NDBM_File; use DB_File;
  2. tie %newhash, 'DB_File', $new_filename, O_CREAT|O_RDWR;
  3. tie %oldhash, 'NDBM_File', $old_filename, 1, 0;
  4. %newhash = %oldhash;

DBM Comparisons

Here's a partial table of features the different packages offer:

  1. odbm ndbm sdbm gdbm bsd-db
  2. ---- ---- ---- ---- ------
  3. Linkage comes w/ perl yes yes yes yes yes
  4. Src comes w/ perl no no yes no no
  5. Comes w/ many unix os yes yes[0] no no no
  6. Builds ok on !unix ? ? yes yes ?
  7. Code Size ? ? small big big
  8. Database Size ? ? small big? ok[1]
  9. Speed ? ? slow ok fast
  10. FTPable no no yes yes yes
  11. Easy to build N/A N/A yes yes ok[2]
  12. Size limits 1k 4k 1k[3] none none
  13. Byte-order independent no no no no yes
  14. Licensing restrictions ? ? no yes no
  • [0]

    on mixed universe machines, may be in the bsd compat library, which is often shunned.

  • [1]

    Can be trimmed if you compile for one access method.

  • [2]

    See DB_File. Requires symbolic links.

  • [3]

    By default, but can be redefined.

SEE ALSO

dbm(3), ndbm(3), DB_File(3), perldbmfilter