Tanktalus gave you useful information, but I'd suggest a major change.

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.


In reply to Re: Glob seekpointer by tilly
in thread Glob seekpointer by Shylock

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.