in reply to Glob seekpointer
Right now you're clearly thinking like a shell programmer. The algorithm that you're using is buggy and O(n*n). It is buggy because if you have fields named "name" and "namespace", your current code will think that it sees the former in the latter. Plus you may mistake data and metadata. Furthermore the last optimization that you're trying to use only saves you about 50% of the total work that you might wind up doing.
You can (and should) do better.
The right approach is to process FIELDS to create a hash of known field names. Then read through your directory, opening each file, parsing out the fieldnames and doing a hash lookup to see whether you're interested in it. If you are then print it to FOUND.
This is admittedly somewhat more complex to do. However it will only have to make one pass through the directory, and produces far more accurate results. For anything more than a one-off, I'd be sold based on reliability alone. The performance win would just be icing on the cake.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Glob seekpointer
by Shylock (Acolyte) on Feb 25, 2005 at 06:23 UTC |