| Next | Lightweight Databases | 25 |
What's with this?
if ($mid) {
seek $fh, $mid-1, SEEK_SET;
my $junk = <$fh>;
} else ...
my $start = tell $fh;
my $rec = <$fh>;
Well, we want the record that starts at or after $mid
But $mid might point into the middle of a record

We back up one space in case it doesn't point into the middle:

Note: This trick only works when length($/) = 1
| Next | ![]() |
Copyright © 2003 M. J. Dominus |