rashichauhan has asked for the wisdom of the Perl Monks concerning the following question:
I want to compare 2 files and create third file with uncommon content.
e.g.
File 1File 2EC:1.1.1.42 isocitratedehydrogenase EC:1.1.1.44 6-phosphogluconatedehydrogenase EC:1.1.1.49 glucose-6-phosphate1-dehydrogenase
Code that I have writtenEC: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 is not working.A new file is genertaed but consist of only last element of first file.Plz help me in this regard.#!/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"; } } }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: comparing 2 files and creating third file with uncommon content
by hippo (Bishop) on Jun 18, 2014 at 10:10 UTC | |
Re: comparing 2 files and creating third file with uncommon content
by Arunbear (Prior) on Jun 18, 2014 at 13:37 UTC | |
by fullermd (Priest) on Jun 18, 2014 at 18:19 UTC | |
Re: comparing 2 files and creating third file with uncommon content
by 2teez (Vicar) on Jun 18, 2014 at 14:26 UTC | |
Re: comparing 2 files and creating third file with uncommon content
by Bloodnok (Vicar) on Jun 18, 2014 at 16:11 UTC | |
Re: comparing 2 files and creating third file with uncommon content
by pvaldes (Chaplain) on Jun 18, 2014 at 19:39 UTC |
Back to
Seekers of Perl Wisdom