rline has asked for the wisdom of the Perl Monks concerning the following question:
Hello,
I have two flatfile databases (let's call them file1 and file2), each with a number of lines. Say, file1 has 2 lines, and file 2 has 4 lines. Each line in each database has exactly the same delimited fields. I need to keep the 2 files separate, though.
I want to take the first line in file1, and then compare it with each of the 4 lines in file2, to see which fields are the same. So out of 10 possible fields, line 1 in file1 might have 6 matches with line 1 file2, 3 matches with line 2 file2, 7 matches with line 3 file2, and 1 match with line4 file2. I then need to be able to list the number of matches for each line of file 2 with line 1 file 1, and state what the matches are.
Once that's done, I want to repeat the above paragraph for the second line in file1. So, I need to treat each line in file 1 separately, but I need to compare it with every line in file 2.
The output might be:
Line 1 of File 1 has 6 matches with file2line1. These are... Line 1 of File 1 has 3 matches with file2line2. These are... etc etc etc Line 2 of File 1 has 8 matches with file2line1. These are... etc etc etc
Is this possible? Is it easy? I have been trying to do it using foreach loops, but my brain can't handle the logic at this stage.
Any ideas?
Thanks
edit - Petruchio Tue Oct 16 11:37:04 UTC 2001: Added markup.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Comparing fields in 1 database with fields in another
by George_Sherston (Vicar) on Oct 16, 2001 at 15:50 UTC | |
by rline (Initiate) on Oct 17, 2001 at 18:08 UTC | |
|
Re: Comparing fields in 1 database with fields in another
by Hofmator (Curate) on Oct 16, 2001 at 15:47 UTC | |
|
Re (tilly) 1: Comparing fields in 1 database with fields in another
by tilly (Archbishop) on Oct 16, 2001 at 16:52 UTC | |
|
(Mappy Approach) Re: Comparing fields in 1 database with fields in another
by Zaxo (Archbishop) on Oct 16, 2001 at 17:06 UTC |