1 ;# Usage: &look(*FILEHANDLE,$key,$dict,$fold)
3 # This library is no longer being maintained, and is included for backward
4 # compatibility with Perl 4 programs which may require it.
6 # In particular, this should not be used as an example of modern Perl
7 # programming techniques.
9 ;# Sets file position in FILEHANDLE to be first line greater than or equal
10 ;# (stringwise) to $key. Pass flags for dictionary order and case folding.
13 local(*FH
,$key,$dict,$fold) = @_;
14 local($max,$min,$mid,$_);
15 local($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,
16 $blksize,$blocks) = stat(FH
);
17 $blksize = 8192 unless $blksize;
18 $key =~ s/[^\w\s]//g if $dict;
19 $key = lc $key if $fold;
20 $max = int($size / $blksize);
21 while ($max - $min > 1) {
22 $mid = int(($max + $min) / 2);
23 seek(FH
,$mid * $blksize,0);
24 $_ = <FH
> if $mid; # probably a partial line
27 s/[^\w\s]//g if $dict;
41 s/[^\w\s]//g if $dict;