Perl dbmclose Function

Advertisements


Description

This function closes the binding between a hash and a DBM file. Use the tie function with a suitable module.

Syntax

Following is the simple syntax for this function:

dbmclose HASH

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.

Example

Following is the example code showing its basic usage:

#!/usr/bin/perl

# print out history file offsets
dbmopen(%HIST,'/usr/lib/news/history',0666);
while (($key,$val) = each %HIST) {
   print $key, ' = ', unpack('L',$val), "\n";
}
dbmclose(%HIST);

When above code is executed, it produced following result:




Advertisements
Advertisements