If I were approaching this problem from a standing start, I would write out all the things I wanted to do in English, but break it up a bit so it reads clearly. So I might get something like:
for each line in File1, look at each line in File2 and for each of the fields in the current line if the field has the same stuff in it as the corresponding fie +ld in the current line of File 2 - remember it, otherwise - fuggedaboudit print out a report of all the stuff I remembered
In practice this might be a mental rather than a manual operation. The advantage of writing it down, with all those suggestive indentations, wd be that one could then take each line and slowly transmogrify it into executable perl. To start with you might rewrite the whole lot, but with the looping operators and accompanying brackets etc written in:
foreach (line in File1) { look at each line in File2; foreach (field in the current line) { if (the field has the same stuff in it as the corresponding fi +eld in the current line of File 2) { remember it; } else { fuggedaboudit; } } } print out a report of all the stuff I remembered;
This obviously still won't execute, but it's a framework that you can then colour in, as it were, by translating each of the non-perl bits into perl. So the first line might become
my @files = ('File1','File2'); my $file; foreach $file (@files) { do stuff with $file ...
In fact you might boil that line down to
foreach $file (File1..File2) { do stuff with $file ...
(which, because perl is wonderful, wd also work for more than two files). In fact you might boil it down further to
for (File1..File2) { do stuff with $_ ...
Then you would go on to the next line of your original outline and re-write that too. And when you get it all translated into perl you should put a -w after the shebang line at the top, and on the next line write use strict; Then when you run it, either it works and you go on your way rejoicing, or it fails but it tells you why.

If that's any help at all, I suggest you write some stuff, fix it up as much as you can and then, if it works, post it in triumph, and if it doesn't work, post it to see if anyone can tell you why.

§ George Sherston

In reply to Re: Comparing fields in 1 database with fields in another by George_Sherston
in thread Comparing fields in 1 database with fields in another by rline

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.