in reply to Re: Compare two Large FlatFiles
in thread Compare two Large FlatFiles

Hi guys, below is my piece of code....please help me in tuning this...only logic I can think with the knowledge I have on Perl :) while(my $pline = <PRFILE>) { $parrecord = $pline; my @parfields=split('\|',$parrecord); chomp(@parfields); # Child file is already loaded into @carray foreach (@carray) { $chrecord = $_; @chfields=split('\|',$chrecord); chomp(@chfields); if(@chfields4 eq @parfields1) { # Some logic # last ; } } } OOOH God...!!!! I was shocked to see the alignment of my code after posting this, but I have no option :)

Replies are listed 'Best First'.
Re^3: Compare two Large FlatFiles
by suneel.reddy (Novice) on Apr 17, 2012 at 10:02 UTC
    Okay here is my problem.....

    record from file1 :

    I|1400000042597061|ACTV|602282|2011-08-29||602178|JUSTIN||MAGRUDER||||||602282|100001|||||Gold||600990|||||||WUSA00029582|529381||||||||||||

    record from file2 :

     I|1400000042589325|2011-08-29|ACTV|1400000042597061|600002|||1556 3RD AVE|||NEW YORK|NY|10128|3100|US|||||||

    Here second field from F1 is eual to 5th field of F2

    And my script...

    while(my $pline = <PRFILE>) { $parrecord = $pline; my @parfields=split('\|',$parrecord); chomp(@parfields); # Child file is already loaded into @carray foreach (@carray) { $chrecord = $_; @chfields=split('\|',$chrecord); chomp(@chfields); if(@chfields[4] eq @parfields[1]) { # Push $chrecord into some array# last ; } } }