#!/usr/bin/perl use BerkeleyDB; my $file = shift || die "usage: $0 file"; %hash = (); my $db = tie %hash, 'BerkeleyDB::Hash', -Filename => $file, -Flags => DB_RDONLY, -Property => DB_DUP | DB_DUPSORT or die "can't read file '$file': $!"; my $ref = $db->db_stat; print "db info: \n", map{" - ${_}: ".$ref->{$_}.$/} keys %$ref; print "db contains ", scalar(keys %hash), " entries\n"; print map { " $_ => $hash{$_}\n" } sort keys %hash; #### #!/usr/bin/perl use DB_File; my $file = shift || die "usage: $0 file"; %hash = (); tie %hash, 'DB_File', $file, O_RDONLY, 0666, DB_HASH or die "can't read file '$file': $!"; print "$file has ", scalar(keys %hash), " entries\n"; print map { " $_ => $hash{$_}\n" } sort keys %hash; #### type parameter is not a reference at /usr/lib/perl5/5.6.1/i386-linux/DB_File.pm line 262.