Next | Lightweight Databases | 28 |
search2.pl in your handout is like search1.pl, but a little more general
It takes a search function that compares records
The function should return a negative value if the current record is too early
search2.pl finds the first record in the file that is not 'too early'
For example, if your file is the password file, sorted on field 2:
search(\*PASSWD, sub { my ($uid) = (split /:/)[1]; $uid <=> 119 });
This locates the first record whose UID is at least 119
Next | Copyright © 2003 M. J. Dominus |