. This module lets you access the lines of a file on disc through an array. You could then use a binary search on the array to find the element. You should need a maximum of 17 or so comparisons for a 100,000 line file to find what you are looking for. That should keep it under 10 seconds even with the cost of disc access. (see the above post for references to a host of discussions on binary searches)