-----------------@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.
In reply to Comparing two files by bman
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |