$DB_BTREE->{'flags'} = R_DUP; $DB_BTREE->{'compare'} = \&_compare; my %btree; my $bhandle = tie %btree, 'DB_File', undef, O_RDWR|O_CREAT, 0640, $DB_HASH; my $len = 26; my @array = ( 'a'..'z' ); foreach ( 1..$len ) { $btree{$_} = shift @array; } # add a second value to each so that each key has duplicate values @array = ( 'A'..'Z' ); foreach ( 1..$len ) { $btree{$_} = shift @array; } # test to see that each value is printed from 20 - end my @v = $bhandle->get_dup(20); print "v is @v 20\n"; while( $bhandle->seq($k,$v, R_NEXT) == 0 ) { my @v = $bhandle->get_dup($k); print "$k @v\n"; } # now associate a single value with a key $btree{22.5} = 'HHI'; # test to see that each value is printed from 20 - end my @v = $bhandle->get_dup(20); print "v is @v 20\n"; while( $bhandle->seq($k,$v, R_NEXT) == 0 ) { my @v = $bhandle->get_dup($k); print "$k @v\n"; } # 22.5 does not show up # add a second value for 22.5 $btree{22.5} = 'JKL'; # test to see that each value is printed from 20 - end my @v = $bhandle->get_dup(20); print "v is @v 20\n"; while( $bhandle->seq($k,$v, R_NEXT) == 0 ) { my @v = $bhandle->get_dup($k); print "$k @v\n"; } # now 22.5 is in the list