I think you will find it of enormous help if you consider what kind of report output(s) you want or what kind of queries will need to be run on this merged version of your two files. Meaning write the user spec of what this will do from a "black box" perspective. A clear understanding of where you want to end up will drive the techniques and structures leading to this result. In other words, the problem is easier if we know where we want to wind up.

Update: Already we have a couple of proposed solutions from bichonfrise74and Bloodnok. The one from bichonfrise74 is organized to make accessing the CGxxx stuff easy. The one from Bloodnok is organized to make accessing the NM_xxx stuff easy. The real question is what best suits your need? It could well be that "none of the above" is the right answer.

another Update: One important thing in an user spec is what to do when "things don't work". You probably have noticed that the critical user data that links the your files doesn't match. So what do you want to do about that? bichonfrise74 ignores those records while Bloodnok generates a data struct with an erroneous value for the last thing when the $NM value is bogus, although it reports that $NM value is undefined. These are the types of things that need to be planned in advance.


In reply to Re: ISOLATE 2 ASSOCIATED FIELDS IN A TEXT FILE, then CONVERT the first into another based on a table of definitions by Marshall
in thread ISOLATE 2 ASSOCIATED FIELDS IN A TEXT FILE, then CONVERT the first into another based on a table of definitions by mupud

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.