DBM Files are good for exact matches, but you aren't doing
an exact match. You are doing a substring match. To do that
efficiently (that is, significantly faster than matching all
files) you either need a complicated datastructure (that you
will have to make persistant somehow) or use lots and lots
of (disk)memory. Or some combination of both. It would also
mean that updating the information is going to take longer.