Upon reviewing this thread, a new concern occurred to me. You may not be getting the results you want with this code. A hash only stores one value for each key,

For example, if your data looks like:

File 1:
a  1
b  2
c  3
d  4
a  5

File2:
a  10
b  11
c  20
c  12

Your output would be something like:

a  5  10
b  2  11
c  3  12
d  4

If you were looking for something like:

a  1   1
a  5  10
b  2  11
c  3  20
c  3  12
d  4
you'll need to make some decions about how you handle duplicate keys in your files.

If you need to keep all your data, I recommend reading the data structures cookbook.

You will also need to move your data out of RAM and onto a disk (DB_File is probably the easiest way), since you won't be overwriting your data. The RAM issues samtregar mentioned will become particularly acute. If you are going to be building complex data structures, MLDBM will work better for you than DB_File.

BTW, to create a hash tied to a DBM file, you can use:

my %file1; tie %file1, "DB_File", "file1.data" ;


TGI says moo


In reply to Re: Perl Code Runs Extremely Slow by TGI
in thread Perl Code Runs Extremely Slow by garbage777

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.