Next Lightweight Databases 83

Indexing Revisited

        sub make_index {
          my ($fh, $dbm, $key_function) = @_;
          seek $fh, 0, SEEK_SET;
          %$dbm = (); 
          my $pos = 0;
          while (<$fh>) {
            chomp;
            my $key = $key_function->($_);
            $dbm->{$key} = $pos;
            $pos = tell $fh;
          }
        }


Next Copyright © 2003 M. J. Dominus