Sorry for the newbie question...
2 files with a common field.
I thought i could just put all the rows into a hash for both tables then just look a hash lookup...
but i seem to be getting memory problems, the process works fine, then just stalls after 1000 records...
May I ask for pointers what i should be looking at doing, ie should i use arrays? hashes? - i dont want to use modules..
thank you!
here is what ive got:

TGR|10 GROUP|www.10group.co.uk#http://www.10group.co.uk#|0121 333 5464 +|johnj beck|info@10group.co.uk| SVG|7 GROUP|www.7group.com|0121 233 1122|tim rice|tim@7.com|
etc... for 4000 records joined to: on field[0]
TGR|10 GROUP|10 GROUP PLC|GB|54|0.40|0.045|200000|GBX| SVG|7 GROUP|7 GROUP PLC ORD|GB|63|1.00|0.35|0.550|5000|GBX|

etc... for 4000 records
and here is my poor excuse for baby perl:
### do original data open(COMPANIES, "+< ./data1") or die "can't open file: $!"; $co = 0; while (<COMPANIES>) { $contents[$co] = $_; $co++; } foreach $record (@contents) { @fields = split(/\|/,$record); $tidm=$fields[0]; etc... $lse{$tidm}++; } close(COMPANIES); ### do data to be merged open(INFO, "+< ./info.csv") or die "can't open file: $!"; $co2 = 0; while (<INFO>) { $contents2[$co2] = $_; $co2++; } foreach $record2 (@contents2) { @fields2 = split(/\|/,$record2); $tidm_inf=$fields2[0]; etc... $merge{$tidm_inf}="$record2"; } close(INFO); ### print merged foreach my $k (sort keys %lse) { print "$merge{$k}\n"; }

In reply to how to merge similar data by alexiskb

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.