in reply to Re: Re: Re: Comparing two files
in thread Comparing two files
A use of PERL's grep function solved my problem in a couple of lines rather than trying to write functions and use hashes.... :-)foreach (@matched) { my @record = split(/,/, $_); my $lic = $record[$#record]; chomp($lic); my ($lname, $fname) = split(/\s+/, uc($record[5])); my $name = "$lname " . substr($fname, 0, 2); # If we find a matching record, then we write it out to a file if (grep /$name/, @phoneBook) { my @line = grep /$name/, @phoneBook; foreach my $rec (0 .. $#line) { if ($rec == 0) { # In case I had more than one record (lik +e the same user multiple times), I only limit results to 1 @line = split(/,/, $line[$rec]); + print RESULTS "$record[0],UNKNOWN,$lic,SLC,$line[0],$l +ine[1],$line[2],$line[3],$line[4],$name\n"; } } } else { chomp(@record); print UNMATCHED "$record[0],$record[5],$record[7],$record[2],$ +record[3],$record[4],UNKNOWN,\\N,\\N\n"; } }
But again, thanks for all your help!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re(5): Comparing two files
by dragonchild (Archbishop) on Sep 13, 2001 at 16:57 UTC | |
by bman (Sexton) on Sep 13, 2001 at 17:33 UTC |