sub hash_init2 { #### DBM Configuration ####################### my $dbm_file = "file.db"; my %hash; local *DBM; my $db = tie %hash, 'MLDBM', $dbm_file, O_CREAT | O_RDWR, 0644 or die "Couldn't not tie to $dbm_file: $!"; my $fd = $db->fd; open DBM, "+<&=$fd" or die "Could not dup DBM for lock : $!"; flock DBM, "LOCK_EX"; undef $db; #Dumper(%hash); return \%hash; } #### sub deleteItem { my ($self, $del_id) = @_; my $hash = hash_init2(); print Dumper($hash); # check if the item actually exists in the database if ( exists($hash->{$del_id}) ) { delete( $hash->{$del_id} ); } untie($hash); }