What have you done so far? You should divide the task into smaller tasks, then it becomes manageble:

1. Reading in file 1. Use split() to get at the single values of the line. I would recommend storing the data into a hash (or probably a HashofHashes or HashofArrays). Yes, that is not easy for a beginner, but there is a lot of documentation in perl books or on the net how to handle complex strucutures like HashofHashes and HashofArrays. For example http://perldoc.perl.org/perlreftut.html

2. Reading in file 2. If you can process each line separately, call a subroutine with each line that does the processing (again to divide the task). If not, storing into a hash might be best to group together all lines with the same key.

3. Merging. Loop through each key of one the files and check out any corresponding data in the second file. Compare, sort and output to a third file. Use subroutines to divide the task into small steps.

Sorry for the very general advice, but you left out so much information about your problem we could give you hundreds of different solutions that would all match your problem description and still would not be what you want. Also this is not a code-for-hire website, we help, but we want to see some effort from your side too.


In reply to Re: merging 2 files to one problem by jethro
in thread merging 2 files to one problem by kjsunny

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.