$hash{ $_ } = undef for 1 .. 1_000_000;
####
undef $foo{ $_ } for 1 .. 1_000_000;
##
##
use DB_File;
tie %hash, 'DB_File', 'tree1M.db'
, O_RDWR|O_CREAT, 0666, $DB_BTREE or die $!;
print time; $hash{ $_ } = undef for 1 .. 1_000_000; print time;
1069482082
1069482433 # 351 secs (5.85 mins)
$n=0;
print time; exists $hash{ $_ } and $n++ for 1 .. 1_000_000; print time, $/, $n;
1069482523
1069482799 # 276 secs (4.6 mins)
1000000
##
##
print time;
$hash{ substr $_, 0, 4 } .= $/. $_ for 1 .. 1_000_000; $hash{$_} .= $/ for keys %hash;
print time;
1069484550
1069484566 # 16 seconds.
$n=0;
print time;
for ( 1 .. 1_000_000 ) {
next unless exists $hash{ substr $_, 0, 4 }
and 1+index( $hash{ substr $_, 0, 4 }, $/ . $_ . $/ );
$n++;
}
print time, $/, $n;
1069484612
1069484656 # 44 secs.
1000000