file1: >AAAT3R length=110 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 38 38 38 38 40 40 39 40 40 40 40 40 40 40 40 40 40 38 38 37 39 36 36 40 36 35 35 35 38 40 35 35 33 35 35 35 40 40 40 40 37 37 38 38 38 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 37 36 36 31 22 22 22 20 20 20 20 20 14 >AAA2OJ length=70 18 18 18 21 35 35 35 32 32 32 33 35 38 39 37 37 39 39 39 39 39 40 40 39 39 39 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 39 39 37 35 35 39 37 37 37 37 37 37 37 37 37 37 33 32 32 30 20 17 17 17 0 file2: >AAAT3R_left length=6 TACATA >AAAT3R_right length=62 ACTACTGATTTGATTATCTTTGATCTCTGTCGAACTAACTATATCTTAGTATGATCTTTAAT >AAA2OJ_left length=14 TTTTGGACTATCTG >AAA2OJ_right length=14 AGGCTGTTCTTTTN result file:(expected) >AAAT3R_left length=6 40 40 40 40 40 40 >AAAT3R_right length=62 40 40 40 38 38 37 39 36 36 40 36 35 35 35 38 40 35 35 33 35 35 35 40 40 40 40 37 37 38 38 38 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 37 36 36 31 22 22 22 20 20 20 20 20 14 >AAA2OJ_left length=14 18 18 18 21 35 35 35 32 32 32 33 35 38 39 >AAA2OJ_right length=14 37 37 37 37 37 33 32 32 30 20 17 17 17 0 #### #!/usr/bin/perl use strict; #processing file2 open(FH1,"file2.txt") or die "cant open"; my @ar=; my $left;my $right;my @final; foreach my $aray(@ar){ if($aray=~m/left/){ if($aray=~m/(^>.*)_\w+\s\w+(=)(\d+)/){ $left=$3; } } else{ my $right_header=$aray; if($aray=~m/(^>.*)_\w+\s\w+(=)(\d+)/){ $right=$3; push(@final,$1); push(@final,"left=$left".".."."right=$right"); } } } my %hash=@final; my $val;my $head; my ($leftnew,$rightnew);my ($side1,$num1);my ($side2,$num2); my @numright;my @numleft;my @string;my @string1; #comparing with file 1 open(FH2,"file1.txt") or die "cant open"; my @ar2=; my $aray2; while (my ($key,$value)=each %hash){ foreach $aray2(@ar2){ if ($aray2=~m/^(>\w+)/){ $head=$1; } $val=$hash{$key}; ($leftnew,$rightnew)=split(/\../,$val); ($side1,$num1)=split(/=/,$leftnew); ($side2,$num2)=split(/=/,$rightnew); @numleft=split(' ',$aray2); @numright=reverse(@numleft); if ($head eq $key){ if($aray2=~m/^\d+/){ my $i;my $j; for($i=0;$i