Perl dbmopen Function



This function Binds the database file specified by EXPR to the hash HASH. If the database does not exist, then it is created using the mode specified by MODE. The file EXPR should be specified without the .dir and .pag extensions. Use is now deprecated in favor of tie and one of the tied DBM hash modules, such as SDBM_File.


Following is the simple syntax for this function −

dbmopen HASH, EXPR, MODE

Return Value

This function returns 0 on failure and 1 on success.

Note that functions such as keys and values may return huge lists when used on large DBM files. You may prefer to use the each function to iterate over large DBM files.


Following is the example code showing its basic usage −


# print out history file offsets
while (($key,$val) = each %HIST) {
   print $key, ' = ', unpack('L',$val), "\n";

When above code is executed, it produces the following result −