in reply to Comparing fields in 1 database with fields in another
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: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
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 becomeforeach (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;
In fact you might boil that line down tomy @files = ('File1','File2'); my $file; foreach $file (@files) { 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 toforeach $file (File1..File2) { do stuff with $file ...
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.for (File1..File2) { do stuff with $_ ...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Comparing fields in 1 database with fields in another
by rline (Initiate) on Oct 17, 2001 at 18:08 UTC |