Two options I can think of:
1. if the two files are relatively small, you can read them both into hashes, where the key is the company name (assuming the company name is what you want to match on) and the value is the whole pipe delimited record. Loop through the 1st hash, like you did in the "for" above, and for each hash element, check for a matching company name in the other hash. This would be the fastest (performance) approach. 2. loop through the records in file 2 - create a hash where the key is the company name, and the value is the whole pipe delimited record. After that loop is done and the hash for file 2 has been created, loop through file 1 records - for each record, see if there is a matching company name in the file 2 hash.
If the files are too big, the last resort might be to have an outer loop to loop through the file 1 records, and an inner loop that for each file 1 record, will loop through all the records in file 2, looking for a company name match.

HTH.

In reply to Re: Flat File Question by hmerrill
in thread Flat File Question by lisaw

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.