Hi Deicide,

it would be most useful to see your code, as well as some samples of your input and desired output.

As a general rule, when you're looking for records (or parts of records) that are in file 2 and not in file 1, the best method is to read file 1 and to store the data of interest of file 1 in a hash; and then to scan file 2 and keep the records not matching the hash. BTW, a hash will remove the duplicates.

Not knowing anything about your input files (e.g., what is the record separator?), I can't suggest any real code. But the basic idea in pseudo-code is:

Open file 1 and read file 1 record by record, and: for (each record) { get column D from the record; get the interesting part from column D; store the interesting part in a hash: some thing like: $hash{inter +esting part} = 1; } close file 1 open file 2 and read file 2 record by record, and: for (each record) { get column D from the record; get the interesting part from column D; if (exists $hash{interesting part}) { print $hash{interesting part}; } } close file 2;

I (and other monks here) will be able to provide actual code if you provide the necessary information (especially sample input and desires output).


In reply to Re: 2 files by Laurent_R
in thread 2 files by Deicide

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.