I tried to read two files and compare them:
file1 : AAAAAAAAAA
file2: AAAABAAAAA
output: MMMMNMMMMM
open(my $fh1, '<', 'file1');
open(my $fh2, '<', 'file2');
while(
defined(my $line1 = <$fh1>)
and
defined(my $line2 = <$fh2>)
){
chomp $line1;
chomp $line2;
my @line1 = split(//, $line1);
my @line2 = split(//, $line2);
for my $i (0 ..@line1-1){
for my $j (0 .. @line2-1){
if ($line1[$i] eq $line2[$j]){
print "M\";}
else {
print "N";}
$j++;}
$i++;}}
close $fh1;
close $fh2;
It prints output repeatedly!! If somebody help me it would be a great help.