Tutorials Point


  Perl Home

  PERL Functions

© 2011 TutorialsPoint.COM


  Home     References     About TP     Advertising  

PERL dbmopen Function



Syntax

dbmopen HASH, EXPR, MODE


Definition and Usage

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.

Return Value

  • 0 on failure

  • 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:

#!/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);



Printer Friendly



  

Advertisement

Online Image Processing

Indian Baby Names