Next Lightweight Databases 46

Indexing

        sub find_user_by_uid {
          my ($fh, $index_fh, $uid) = @_;
          seek $index_fh, $uid * 10, SEEK_SET;
          if (read($index_fh, my($rec), 10) == 10) {
            my ($offset) = unpack "A10", $rec;
            seek $fh, $offset, SEEK_SET;
            my $record = <$fh>;
            return defined $record ? split /:/, $record : ();        
          }
          return;
        }


Next Copyright © 2003 M. J. Dominus