AnyDBM_File(3perl)
π AnyDBM_File(3perl) β the group chat version π
okay bestie, sit down, hydrate, because today we're talking about AnyDBM_File, which lives in the Perl Programmers Reference Guide and is genuinely one of those quiet little modules that's been holding everything together since forever.
Also riding along in this same page, because they're all part of the same vibe: NDBM_File, DB_File, GDBM_File, SDBM_File, and ODBM_File β a.k.a. the various DBM implementations. π
β¨ NAME β¨
AnyDBM_File β it's the framework for multiple DBMs, periodt. π
And also: NDBM_File, DB_File, GDBM_File, SDBM_File, ODBM_File β the various DBM implementations, all hanging out together.
πΈ SYNOPSIS πΈ
use AnyDBM_File;
that's it. that's the whole synopsis. slay. π
π¦ DESCRIPTION π¦
ngl, this module is a "pure virtual base class" β which is a fancy way of saying it has nothing of its own. Like, zero. It's literally just there so it can inherit from one of the various DBM packages. it's giving middle manager energy and honestly? we respect it. π
So here's the priority order it picks from:
- it prefers
ndbm, for compatibility reasons with Perl 4 π§ - then Berkeley DB (See
DB_File) - then GDBM
- then SDBM β which is always there, it comes with Perl, she's the reliable friend π
- and finally ODBM
This way, old programs that used to use NDBM via dbmopen() can still do so π but new ones can reorder @ISA however they want:
BEGIN { @AnyDBM_File::ISA = qw(DB_File GDBM_File NDBM_File) }
use AnyDBM_File;
Having multiple DBM implementations around makes it trivial to copy database formats, which is genuinely so cute:
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;
look at her go. copying formats like it's nothing. π₯
π DBM Comparisons π
Here's a partial table of features the different packages offer. Heads up bestie, the columns are odbm, ndbm, sdbm, gdbm, and bsd-db β I'm gonna list them out one feature at a time so nobody's eyes glaze over. π
- Linkage comes w/ perl β
odbm: yes,ndbm: yes,sdbm: yes,gdbm: yes,bsd-db: yes - Src comes w/ perl β
odbm: no,ndbm: no,sdbm: yes,gdbm: no,bsd-db: no - Comes w/ many unix os β
odbm: yes,ndbm: yes[0],sdbm: no,gdbm: no,bsd-db: no - Builds ok on !unix β
odbm: ?,ndbm: ?,sdbm: yes,gdbm: yes,bsd-db: ? - Code Size β
odbm: ?,ndbm: ?,sdbm: small,gdbm: big,bsd-db: big - Database Size β
odbm: ?,ndbm: ?,sdbm: small,gdbm: big?,bsd-db: ok[1] - Speed β
odbm: ?,ndbm: ?,sdbm: slow,gdbm: ok,bsd-db: fast - FTPable β
odbm: no,ndbm: no,sdbm: yes,gdbm: yes,bsd-db: yes - Easy to build β
odbm: N/A,ndbm: N/A,sdbm: yes,gdbm: yes,bsd-db: ok[2] - Size limits β
odbm: 1k,ndbm: 4k,sdbm: 1k[3],gdbm: none,bsd-db: none - Byte-order independent β
odbm: no,ndbm: no,sdbm: no,gdbm: no,bsd-db: yes - Licensing restrictions β
odbm: ?,ndbm: ?,sdbm: no,gdbm: yes,bsd-db: no
and the footnotes, because of course there are footnotes π:
- [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
go read those too bestie, they're all part of the lore. π
lowkey reminder: this whole page is from perl v5.44.0, dated 2026-10-17, and it's the AnyDBM_File(3perl) manual page. mwah. πβ¨π
π¦ where this page comes from
- arch rolling: perl 5.44.0-1 Β· Artistic-1.0-Perl AND GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms