10 Search::Dict, look - search for key in dictionary file
15 look *FILEHANDLE, $key, $dict, $fold;
19 Sets file position in FILEHANDLE to be first line greater than or equal
20 (stringwise) to I<$key>. Returns the new file position, or -1 if an error
23 The flags specify dictionary order and case folding:
25 If I<$dict> is true, search by dictionary order (ignore anything but word
26 characters and whitespace).
28 If I<$fold> is true, ignore case.
33 local(*FH,$key,$dict,$fold) = @_;
37 my($size, $blksize) = @stat[7,11];
39 $key =~ s/[^\w\s]//g if $dict;
40 $key =~ tr/A-Z/a-z/ if $fold;
41 my($min, $max, $mid) = (0, int($size / $blksize));
42 while ($max - $min > 1) {
43 $mid = int(($max + $min) / 2);
44 seek(FH, $mid * $blksize, 0)
46 <FH> if $mid; # probably a partial line
49 s/[^\w\s]//g if $dict;
51 if (defined($_) && $_ lt $key) {
67 s/[^\w\s]//g if $dict;