bman has asked for the wisdom of the Perl Monks concerning the following question:
-----------------@matched = sort @matched; @phoneBook = sort @phoneBook; foreach (@phoneBook) { @fields = split(',', $_); my $fullname = $fields[0]; $fullname =~ tr/[()]//d; $fullname =~ s/\s+/ /; foreach (@matched) { my @record = split(',', $_); my $lic = $record[$#record]; chomp($lic); my ($lname, $fname) = split('\s+', $record[5]); my $firstn = substr($fname, 0, 2); my $name = "$lname " . "$firstn"; $name =~ tr/[a-z]/A-Z/; if (defined $fullname =~ m/$name/g) { print RESULTS "$record[0],UNKNOWN,$lic,$fullname,$fields[1 +],$fields[2],$fields[3]\n"; } } }
What I am doing is comparing names from one file (inner loop) against a bigger file (outer file). If it matches, I simply want to write it out. But it's not happening here. If everything goes fine, I should get about 154 matches. However, I'm getting over 90,000 of them (while the outer loop file contains only about 260 records). Can someone, please tell me what's going on here?
On the same note, then, I want to find out how many records from the inner file do not match the outer. My thinking was "I would simply reverse the loops and do !~." This, however, also seems not to work.
At this point, I would greatly appreciate any hints, directions I should take to resolve it.
Thanks.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Comparing two files
by japhy (Canon) on Sep 10, 2001 at 17:35 UTC | |
|
Re: Comparing two files
by dragonchild (Archbishop) on Sep 10, 2001 at 17:40 UTC | |
by bman (Sexton) on Sep 10, 2001 at 19:17 UTC | |
by dragonchild (Archbishop) on Sep 10, 2001 at 19:39 UTC | |
by bman (Sexton) on Sep 13, 2001 at 16:23 UTC | |
by dragonchild (Archbishop) on Sep 13, 2001 at 16:57 UTC | |
| |
|
Re: Comparing two files
by physi (Friar) on Sep 10, 2001 at 17:35 UTC |