http://qs1969.pair.com?node_id=209103


in reply to comparing strings

I think getting one scalar out of a pair of arrays is going to give you one list (rather than the pair you want to compare). You can try this by adding a print $base line right inside the loop and seeing how many times it loops. Also, unless lines1 is an array of arrays, you want to get your character from it through a scalar like $lines1[0].

Depending on how good you are with perl you might find the following alternate too simple (or too c-like) but the foreach loop can replace the for loop (I think). And I never liked shifting.

# e.g @lines1 contains CACTATGAGTGATCGC and @lines2 contains # ACTGACTAATGCGTTG. @lines1= split(//,"CACTATGAGTGATCGC"); @lines2= split(//,"ACTGACTAATGCGTTG"); $line1length=@lines1; $line2length=@lines2; print ("1 :",@lines1,"\n"); print ("2 :",@lines2,"\n"); if ($line1length!=$line2length) { print "Length Mismatch\n"; } else { print "M :"; for ($x=0;$x<$line1length;$x++) { if ($lines1[$x] eq $lines2[$x]) { print $lines1[$x]; } else { print "*"; } } print "\n"; }

-- termix