#!/usr/bin/perl -w ## ## txt2dbm -- convert txt map to dbm format ## use BerkeleyDB; use Fcntl; ($txtmap, $dbmmap) = @ARGV; open(TXT, "<$txtmap") or die "Couldn't open $txtmap!\n"; tie (%DB, 'BerkeleyDB::Hash', -Filename => $dbmmap) or die "Couldn't create $dbmmap!\n"; # use -Flags => DB_CREATE to create the database while () { next if (/^\s*#/ or /^\s*$/); if (/^\s*(\S+)\s+(\S+)/) { print "added key $1 with value $2\n" if (!defined($DB{$1})); $DB{$1} = $2 ; } } untie %DB; close(TXT);