$s1 = "\0"; $s2 = $s1 x 2; my $diff_pos = ($s1 ^ $s2) =~ /[^\0]/ ? $-[0] : undef; print defined $diff_pos ? "diff_pos says the strings differ at $diff_pos\n" : "diff_pos says the strings are equal.\n"; print $s1 eq $s2 ? "and Perl says they are equal\n" : "and Perl says they are not equal\n";