I want to compare 2 files and create third file with uncommon content.
e.g.
File 1
EC:1.1.1.42 isocitratedehydrogenase
EC:1.1.1.44 6-phosphogluconatedehydrogenase
EC:1.1.1.49 glucose-6-phosphate1-dehydrogenase
File 2
EC:1.1.1.42 isocitratedehydrogenase
EC:1.1.1.44 6-phosphogluconatedehydrogenase
EC:1.1.1.49 glucose-6-phosphate1-dehydrogenase
EC:1.11.1.9 glutathioneperoxidase
EC:2.5.1.16 spermidinesynthase
EC:6.3.1.8 glutathionesynthase
Code that I have written
#!/usr/bin/perl
$dir = "C:/Perl/bin/kegg";
open (FILE3,">>","$dir/keggdifference1.txt");
open (FILE4,">>","$dir/keggdifference2.txt");
open (FILE,"<","$dir/common.txt");
while (<FILE>) {
chomp ($file=$_);
@array =split (/\t/,"$file");
#print "$array[0]\n";
}
open (FILE1,"<","$dir/bacillus1.txt");
while (<FILE1>) {
chomp ($file1=$_);
@array1 =split (/\t/,"$file1");
#print "$array1[3]\n";
}
foreach ($array[0])
{
foreach ($array1[3])
{
if($array[0] eq $array1[3])
{
print FILE3 "$array[0]\n";
}
else
{
print FILE4 "$array[0]\n";
}
}
}
Code is not working.A new file is genertaed but consist of only last element of first file.Plz help me in this regard.