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.
5 # This legacy library is deprecated and will be removed in a future
8 # In particular, this should not be used as an example of modern Perl
9 # programming techniques.
11 ;# Sets file position in FILEHANDLE to be first line greater than or equal
12 ;# (stringwise) to $key. Pass flags for dictionary order and case folding.
15 local(*FH,$key,$dict,$fold) = @_;
16 local($max,$min,$mid,$_);
17 local($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,
18 $blksize,$blocks) = stat(FH);
19 $blksize = 8192 unless $blksize;
20 $key =~ s/[^\w\s]//g if $dict;
21 $key = lc $key if $fold;
22 $max = int($size / $blksize);
23 while ($max - $min > 1) {
24 $mid = int(($max + $min) / 2);
25 seek(FH,$mid * $blksize,0);
26 $_ = <FH> if $mid; # probably a partial line
29 s/[^\w\s]//g if $dict;
43 s/[^\w\s]//g if $dict;