Leser: 18
$diff =~ tr/\0//d
1 2 3 4 5 6 7 8 9 10
use strict; use warnings; my $s1 = 'abcdefghijklmnopqrstuvwxyz'; my $s2 = 'abcdefghijklaaaaarstuvwxyz'; my $diff = $s1 ^ $s2; $diff =~ tr/\0//d; print length( $diff ) . "\n";
perl -e 'my $x="ABCDE"; $y="BBCCD"; $diff=$x ^ $y; $count=$diff=~tr/\0//c; print unpack("B*",$x)."\n".unpack("B*",$y)."\n".unpack("B*",$diff)." ($count)\n";'
1
2
3
0100000101000010010000110100010001000101
0100001001000010010000110100001101000100
0000001100000000000000000000011100000001 (3)
2009-07-27T14:34:12 gh057Zur Erklaerung: Ich moechte wissen wieviele Zeichen in zwei gleich langen Strings verschieden sind.