Next Lightweight Databases 84

Indexing Revisited

        use DB_File;
        tie %by_name, 'DB_File', "./pw_aux", O_CREAT|O_RDWR, 0666
          or die $!;
        open PASSWD, "<", "/etc/passwd" or die $!;
        make_index(\*PASSWD, \%by_name, 
                   sub { (split /:/, $_[0], 2)[0] },
                  );
        print find(\*PASSWD, \%by_name, "mjd");
     mjd:x:119:100:Mark Jason Dominus:/home/mjd:/bin/bash


Next Copyright © 2003 M. J. Dominus