R
Rider
Hi experts,
I have two files, each one with 100's of entries. Each line in each
file has two id's, seperated by a single.
I want to compare both files and need to print which ones are matching
and which ones are not matching.
I am looking out for a simple code that just compares the whole lines
in both files and throw the differences in another file,
non_matching.txt and matched ones in to matching.txt
Can some one suggest a simple way of achieving this?
Example:
file1.txt
+++++++++++
bsmith \t rmiller
rcarter \t bsmith
qyang \t rsingh
file2.txt
+++++++++++
bsmith \t rmiller
rcarter \4 sdung
qyang \t sreddy
matching.txt should be (only first id is required in the output, as it
is common in both both files and only the second id per line might
change in the second file).
+++++++++++++++++
bsmith
++++++++++++++++
non_matching.txt should be
++++++++++++++
rcarter \4 sdung
qyang \t sreddy
++++++++++++++
This is what I am thinking:
+++++++++++++++++++++++++
my %myconfig = (
input1 => 'file1.txt.',
input2 => 'file2.txt.',
matching => 'matching.txt',
non_matching => 'not_matchingtxt',
);
my %fields2;
{
open my $input, '<', $myconfig{input1} or die "Cannot open
'$myconfig{input1}': $!";
while ( <$input> )
{
.......
}
I have two files, each one with 100's of entries. Each line in each
file has two id's, seperated by a single.
I want to compare both files and need to print which ones are matching
and which ones are not matching.
I am looking out for a simple code that just compares the whole lines
in both files and throw the differences in another file,
non_matching.txt and matched ones in to matching.txt
Can some one suggest a simple way of achieving this?
Example:
file1.txt
+++++++++++
bsmith \t rmiller
rcarter \t bsmith
qyang \t rsingh
file2.txt
+++++++++++
bsmith \t rmiller
rcarter \4 sdung
qyang \t sreddy
matching.txt should be (only first id is required in the output, as it
is common in both both files and only the second id per line might
change in the second file).
+++++++++++++++++
bsmith
++++++++++++++++
non_matching.txt should be
++++++++++++++
rcarter \4 sdung
qyang \t sreddy
++++++++++++++
This is what I am thinking:
+++++++++++++++++++++++++
my %myconfig = (
input1 => 'file1.txt.',
input2 => 'file2.txt.',
matching => 'matching.txt',
non_matching => 'not_matchingtxt',
);
my %fields2;
{
open my $input, '<', $myconfig{input1} or die "Cannot open
'$myconfig{input1}': $!";
while ( <$input> )
{
.......
}