Dear Monks, I have a question for file handling. I have two files named DUMP_A and DUMP_B and both the files has records close to 5 million. The scenario is - DUMP_A contains only unique id and DUMP_B contains unique id, account number. Here I have to take a record from DUMP_A and compare this unique id with DUMP_B unique id; if it matches then unique id and the corresponding account number has to be write into an another file. The unique number can have more than one account number. Here, in my code the comparison takes more than 12 hours and still the script is running. Kindly look into the script and guide me on this.
open(A, "<" . DUMP_A) || die("Could not open file \n"); open(B, "<" . DUMP_B) || die("Could not open file \n"); open(OUTPUT,">" . INACTIVE_LIST) || die ("Could not write to file \n") +; my $readA; my $readB; while(defined($readA = <A>)){ $readA =~ s!\s+!!g; #chomp($readA); my $a_ID = $readA; while(defined($readB = <B>)){ chomp($readB); my ($b_ID, $b_acctno)=split(/\|/,$readB); # Check both the GUIDs are same if($a_ID =~ m/^$b_ID/i){ #if($a_ID eq $b_ID){ print OUTPUT "$a_ID|$b_ID \n"; } } seek(B,0,0); } close(OUTPUT); close(A); close(B);
- Thank you.

In reply to Reg: Performance by sivaraman

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.