Dict.pm revision 7c478bd95313f5f23a4c958a745db2134aa03244
require 5.000;
require Exporter;
=head1 NAME
Search::Dict, look - search for key in dictionary file
=head1 SYNOPSIS
use Search::Dict;
look *FILEHANDLE, $key, $dict, $fold;
=head1 DESCRIPTION
Sets file position in FILEHANDLE to be first line greater than or equal
(stringwise) to I<$key>. Returns the new file position, or -1 if an error
occurs.
The flags specify dictionary order and case folding:
If I<$dict> is true, search by dictionary order (ignore anything but word
characters and whitespace).
If I<$fold> is true, ignore case.
=cut
sub look {
local($_);
or return -1;
$blksize ||= 8192;
or return -1;
$_ = <FH>;
chop;
s/[^\w\s]//g if $dict;
$_ = lc $_ if $fold;
if (defined($_) && $_ lt $key) {
}
else {
}
}
or return -1;
for (;;) {
defined($_ = <FH>)
or last;
chop;
s/[^\w\s]//g if $dict;
$_ = lc $_ if $fold;
last if $_ ge $key;
}
$min;
}
1;