The following is a program to find out where changes are present in mutiple sequences, but this tells only the locations in number. I need to find out the particular change, for example:
source string: ATGCTTG string 1: ACGCGTG
The following program gives the output as "2,5", but I need the output as [T/C],[T/G], i.e. T has been replaced by C in the second position and also T has been replaced by G in the fifth position.
use strict;
use warnings;
print "Enter the source string";
my $str_source=<>;
print "Enter the 1st strng:";
my $str1=<>;
print "Enter the 2nd string:";
my $str2=<>;
print "Enter the 3rd string";
my $str3=<>;
print "Enyer the 4th string";
my $str4=<>;
sub diff_index
{
my($a,$b)=@_;
my $cmp=$a^$b;
my @cmp;
while($cmp=~/[^\0]/g)
{
push @cmp, pos($cmp)-1;
}
return @cmp;
}
for my $str ( $str_source, $str1, $str2, $str3,$str4 )
{
print "$str";
my @ret = diff_index $str_source, $str;
if( @ret )
{
print"@ret" ;
}
else
{
print "match";
}
}
why don't you just align it, instead of developing a home-made solution?