{
    "mode": "perldoc",
    "parameter": "GDBM_File",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/GDBM_File/json",
    "generated": "2026-06-13T10:48:26Z",
    "synopsis": "use GDBMFile;\n[$db =] tie %hash, 'GDBMFile', $filename, &GDBMWRCREAT, 0640;\n# Use the %hash array.\n$e = $db->errno;\n$e = $db->syserrno;\n$str = $db->strerror;\n$bool = $db->needsrecovery;\n$db->clearerror;\n$db->reorganize;\n$db->sync;\n$n = $db->count;\n$n = $db->flags;\n$str = $db->dbname;\n$db->cachesize;\n$db->cachesize($newsize);\n$n = $db->blocksize;\n$bool = $db->syncmode;\n$db->syncmode($bool);\n$bool = $db->centfree;\n$db->centfree($bool);\n$bool = $db->coalesce;\n$db->coalesce($bool);\n$bool = $db->mmap;\n$size = $db->mmapsize;\n$db->mmapsize($newsize);\n$db->recover(%args);\nuntie %hash ;",
    "sections": {
        "NAME": {
            "content": "GDBMFile - Perl5 access to the gdbm library.\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "use GDBMFile;\n[$db =] tie %hash, 'GDBMFile', $filename, &GDBMWRCREAT, 0640;\n# Use the %hash array.\n\n$e = $db->errno;\n$e = $db->syserrno;\n$str = $db->strerror;\n$bool = $db->needsrecovery;\n\n$db->clearerror;\n\n$db->reorganize;\n$db->sync;\n\n$n = $db->count;\n\n$n = $db->flags;\n\n$str = $db->dbname;\n\n$db->cachesize;\n$db->cachesize($newsize);\n\n$n = $db->blocksize;\n\n$bool = $db->syncmode;\n$db->syncmode($bool);\n\n$bool = $db->centfree;\n$db->centfree($bool);\n\n$bool = $db->coalesce;\n$db->coalesce($bool);\n\n$bool = $db->mmap;\n\n$size = $db->mmapsize;\n$db->mmapsize($newsize);\n\n$db->recover(%args);\n\nuntie %hash ;\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "GDBMFile is a module which allows Perl programs to make use of the facilities provided by the\nGNU gdbm library. If you intend to use this module you should really have a copy of the gdbm\nmanualpage at hand.\n\nMost of the libgdbm.a functions are available through the GDBMFile interface.\n\nUnlike Perl's built-in hashes, it is not safe to \"delete\" the current item from a GDBMFile tied\nhash while iterating over it with \"each\". This is a limitation of the gdbm library.\n",
            "subsections": []
        },
        "STATIC METHODS": {
            "content": "GDBMversion\n$str = GDBMFile->GDBMversion;\n@ar = GDBMFile->GDBMversion;\n\nReturns the version number of the underlying libgdbm library. In scalar context, returns the\nlibrary version formatted as string:\n\nMINOR.MAJOR[.PATCH][ (GUESS)]\n\nwhere *MINOR*, *MAJOR*, and *PATCH* are version numbers, and *GUESS* is a guess level (see\nbelow).\n\nIn list context, returns a list:\n\n( MINOR, MAJOR, PATCH [, GUESS] )\n\nThe *GUESS* component is present only if libgdbm version is 1.8.3 or earlier. This is because\nearlier releases of libgdbm did not include information about their version and the GDBMFile\nmodule has to implement certain guesswork in order to determine it. *GUESS* is a textual\ndescription in string context, and a positive number indicating how rough the guess is in list\ncontext. Possible values are:\n\n1 - exact guess\nThe major and minor version numbers are guaranteed to be correct. The actual patchlevel is\nmost probably guessed right, but can be 1-2 less than indicated.\n\n2 - approximate\nThe major and minor number are guaranteed to be correct. The patchlevel is set to the upper\nbound.\n\n3 - rough guess\nThe version is guaranteed to be not newer than *MAJOR*.*MINOR*.\n",
            "subsections": []
        },
        "METHODS": {
            "content": "close\n$db->close;\n\nCloses the database. You are not advised to use this method directly. Please, use untie instead.\n\nerrno\n$db->errno\n\nReturns the last error status associated with this database.\n\nsyserrno\n$db->syserrno\n\nReturns the last system error status (C \"errno\" variable), associated with this database,\n\nstrerror\n$db->strerror\n\nReturns textual description of the last error that occurred in this database.\n\nclearerror\n$db->clearerror\n\nClear error status.\n\nneedsrecovery\n$db->needsrecovery\n\nReturns true if the database needs recovery.\n\nreorganize\n$db->reorganize;\n\nReorganizes the database.\n\nsync\n$db->sync;\n\nSynchronizes recent changes to the database with its disk copy.\n\ncount\n$n = $db->count;\n\nReturns number of keys in the database.\n\nflags\n$db->flags;\n\nReturns flags passed as 4th argument to tie.\n\ndbname\n$db->dbname;\n\nReturns the database name (i.e. 3rd argument to tie.\n\ncachesize\n$db->cachesize;\n$db->cachesize($newsize);\n\nReturns the size of the internal GDBM cache for that database.\n\nCalled with argument, sets the size to *$newsize*.\n\nblocksize\n$db->blocksize;\n\nReturns the block size of the database.\n\nsyncmode\n$db->syncmode;\n$db->syncmode($bool);\n\nReturns the status of the automatic synchronization mode. Called with argument, enables or\ndisables the sync mode, depending on whether $bool is true or false.\n\nWhen synchronization mode is on (true), any changes to the database are immediately written to\nthe disk. This ensures database consistency in case of any unforeseen errors (e.g. power\nfailures), at the expense of considerable slowdown of operation.\n\nSynchronization mode is off by default.\n\ncentfree\n$db->centfree;\n$db->centfree($bool);\n\nReturns status of the central free block pool (0 - disabled, 1 - enabled).\n\nWith argument, changes its status.\n\nBy default, central free block pool is disabled.\n\ncoalesce\n$db->coalesce;\n$db->coalesce($bool);\n\nmmap\n$db->mmap;\n\nReturns true if memory mapping is enabled.\n\nThis method will croak if the libgdbm library is complied without memory mapping support.\n\nmmapsize\n$db->mmapsize;\n$db->mmapsize($newsize);\n\nIf memory mapping is enabled, returns the size of memory mapping. With argument, sets the size\nto $newsize.\n\nThis method will croak if the libgdbm library is complied without memory mapping support.\n\nrecover\n$db->recover(%args);\n\nRecovers data from a failed database. %args is optional and can contain following keys:\n\nerr => sub { ... }\nReference to code for detailed error reporting. Upon encountering an error, recover will\ncall this sub with a single argument - a description of the error.\n\nbackup => \\$str\nCreates a backup copy of the database before recovery and returns its filename in $str.\n\nmaxfailedkeys => $n\nMaximum allowed number of failed keys. If the actual number becomes equal to *$n*, recover\naborts and returns error.\n\nmaxfailedbuckets => $n\nMaximum allowed number of failed buckets. If the actual number becomes equal to *$n*,\nrecover aborts and returns error.\n\nmaxfailures => $n\nMaximum allowed number of failures during recovery.\n\nstat => \\%hash\nReturn recovery statistics in *%hash*. Upon return, the following keys will be present:\n\nrecoveredkeys\nNumber of successfully recovered keys.\n\nrecoveredbuckets\nNumber of successfully recovered buckets.\n\nfailedkeys\nNumber of keys that failed to be retrieved.\n\nfailedbuckets\nNumber of buckets that failed to be retrieved.\n",
            "subsections": []
        },
        "AVAILABILITY": {
            "content": "gdbm is available from any GNU archive. The master site is \"ftp.gnu.org\", but you are strongly\nurged to use one of the many mirrors. You can obtain a list of mirror sites from\n<http://www.gnu.org/order/ftp.html>.\n",
            "subsections": []
        },
        "SECURITY AND PORTABILITY": {
            "content": "Do not accept GDBM files from untrusted sources.\n\nGDBM files are not portable across platforms.\n\nThe GDBM documentation doesn't imply that files from untrusted sources can be safely used with\n\"libgdbm\".\n\nA maliciously crafted file might cause perl to crash or even expose a security vulnerability.\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "",
            "subsections": [
                {
                    "name": "perl",
                    "content": ""
                }
            ]
        }
    },
    "summary": "GDBMFile - Perl5 access to the gdbm library.",
    "flags": [],
    "examples": [],
    "see_also": []
}