Hi all, I am trying to write a perl program that compares 2 files and writes the difference to the output file as, Example File1 aa bb ac ad File2 bb cc cd Resultant File cc cd Resultant file should contains only those records that are present in second file but not in the first file. bb is present in File1. But cc and cd of file2 are no where present in file1. Please suggest what is the best way to implement this. I am thinking of the following approach Read files into arrays(one line as an array element), sort them. Loop thru all the line of file2 check if the file is not present int file1. But it doesnt seems to be like good approch. Please suggest on this. Please provide any link or a sample snippet. Thanks in advance.

In reply to File Comparision by jagdish1206

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.