You seem to be loading your first csv file into a hash called %subRcd, but then you are never using that hash anywhere else in the code (it's "write-only").

Maybe you should read your second file into that same hash (assuming that the contents of both files are structured the same way, or at least that it's easy to tell them apart in terms of their contents).

When the second file has a key field that matches something in the first file, you'll need to update the hash value for that key, in order to combine the info from the two files into the one record. Apart from that, keys that occur only in the "master" will remain unmodified in the hash, and keys that occur only in the second file will be loaded and kept as-is in the hash.

Then just print out all the hash elements to get the complete union of contents from the two files.

(But I really like Plankton's idea of using SQLite -- definitely worthwhile. Also, you really should start with use strict; and use warnings; -- it will make you a better programmer, and you'll grow to appreciate it.)


In reply to Re^3: How to go about this? by graff
in thread How to go about this? by meredib

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.