Skip Menu |

This queue is for tickets about the BerkeleyDB CPAN distribution.

Report information
The Basics
Id: 96420
Status: new
Priority: 0/
Queue: BerkeleyDB

People
Owner: Nobody in particular
Requestors: ROOTKWOK [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Inconsistent Behavior with delete function on Tied hash vs Perl's Hash
Date: Fri, 13 Jun 2014 15:50:47 +0800
To: bug-BerkeleyDB [...] rt.cpan.org
From: "Baggio, Kwok Lok Chung" <rootkwok [...] cpan.org>
Hello, For perl hash, the delete function wolud return the value of the corresponding key, but tied BerkeleyDB Hash didn't. For example this code snipset won't print "red". It would be far better if someone want a drop in replacement for the hash which share between processes. #!/usr/bin/perl use strict ; use BerkeleyDB ; use vars qw( %h $k $v ) ; my $filename = "fruit" ; unlink $filename ; tie %h, "BerkeleyDB::Hash", -Filename => $filename, -Flags => DB_CREATE or die "Cannot open file $filename: $! $BerkeleyDB::Error\n" ; # Add a few key/value pairs to the file $h{"apple"} = "red" ; $h{"orange"} = "orange" ; $h{"banana"} = "yellow" ; $h{"tomato"} = "red" ; # Delete a key/value pair. print delete $h{"apple"},"\n"; untie %h ; BR, -- /Baggio/