# man > AnyDBM_File(3pm)

---
type: CommandReference
command: AnyDBM_File
mode: perldoc
section: 3perl
source: perldoc
---

## Quick Reference
- `use AnyDBM_File;` — Load default DBM backend (ndbm, DB_File, GDBM, SDBM, ODBM in that order)
- `BEGIN { @AnyDBM_File::ISA = qw(DB_File GDBM_File NDBM_File) }` — Override DBM backend preference before loading
- `tie %hash, 'AnyDBM_File', $file, O_RDWR|O_CREAT, 0644;` — Tie a hash to a DBM file using default or overridden backend
- `untie %hash;` — Untie hash
- `tie %new, 'DB_File', $newfile, O_RDWR|O_CREAT; tie %old, 'NDBM_File', $oldfile, 1,0; %new = %old;` — Copy a database between DBM formats

## Name
AnyDBM_File - provide framework for multiple DBMs. Also covers NDBM_File, DB_File, GDBM_File, SDBM_File, ODBM_File - various DBM implementations.

## Synopsis
perl
use AnyDBM_File;
Optionally reorder preferred backends before loading:
perl
BEGIN { @AnyDBM_File::ISA = qw(DB_File GDBM_File NDBM_File) }
use AnyDBM_File;
## Description
This module is a pure virtual base class—it has nothing of its own. It inherits from one of the various DBM packages, preferring ndbm for compatibility with Perl 4, then Berkeley DB (`DB_File`), GDBM, SDBM (always present, comes with Perl), and finally ODBM. This allows old programs that used `dbmopen()` with NDBM to continue working.

### DBM Comparisons

| Feature                   | odbm   | ndbm   | sdbm   | gdbm   | bsd-db  |
|---------------------------|--------|--------|--------|--------|---------|
| Linkage comes w/ perl     | yes    | yes    | yes    | yes    | yes     |
| Src comes w/ perl         | no     | no     | yes    | no     | no      |
| Comes w/ many unix os     | yes    | yes[0] | no     | no     | no      |
| Builds ok on !unix        | ?      | ?      | yes    | yes    | ?       |
| Code Size                 | ?      | ?      | small  | big    | big     |
| Database Size             | ?      | ?      | small  | big?   | ok[1]   |
| Speed                     | ?      | ?      | slow   | ok     | fast    |
| FTPable                   | no     | no     | yes    | yes    | yes     |
| Easy to build             | N/A    | N/A    | yes    | yes    | ok[2]   |
| Size limits               | 1k     | 4k     | 1k[3]  | none   | none    |
| Byte-order independent    | no     | no     | no     | no     | yes     |
| 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.

## Examples
Copying between DBM formats:
perl
use Fcntl;
use NDBM_File;
use DB_File;
tie %newhash, 'DB_File', $new_filename, O_CREAT|O_RDWR;
tie %oldhash, 'NDBM_File', $old_filename, 1, 0;
%newhash = %oldhash;
## See Also
- [dbm(3)](http://localhost/phpMan.php/man/dbm/3/markdown)
- [ndbm(3)](http://localhost/phpMan.php/man/ndbm/3/markdown)
- [DB_File(3)](http://localhost/phpMan.php/man/DB_File/3/markdown)
- [perldbmfilter](http://localhost/phpMan.php/perldoc/perldbmfilter/markdown)

## Exit Codes
None documented.