Just a thought for fun, something like the following might work, of course it is stripped to show the general idea. create an array with 9,999,999 entries. create a bit mask for each area code. place the appropriate bitmask in the array entry corresponding to the phone number, this allows you to store 8 area codes per byte of data stored.
of course all edit checks, warnings etc are stripped.
#!/usr/bin/perl
open in,"987.txt" or die " could not open 987.txt as input";
# assign bit mask for this area code and pack it to binary
$a = "00000001";
$b = pack('b8',$a);
# load an array with the phone number less the area code as the subscr
+ipt
@arr;
while (<in>){
chomp;
$arr[$_]=$b;
}
# takes time to load about 10 seconds for all 10 million recs
print "\n\narray loaded\n";
# response for lookup is sub-second
while (true){
print "enter phone number: ";
$pni = <>;
chomp $pni;
$pna = unpack('b8',$arr[$pni]);
if (substr($pna,7,1) eq "1" ){
print "on file\n";
}else{
print "not on file\n";
}
}