if (my $pos=$str1 ne $str2) { print "A:$str1\nB:$str2\n"; print "A and B are different at the $pos'th char (index ".($pos-1).")\n"; }