$ perl -le' my $varA = "This is the wild cat"; my $varB = "Thsi is the widl cat"; my $temp = $varA ^ $varB; my @fields; unshift @fields, [ $+[0], $-[0] ] while $temp =~ /[^\0]+/g; my $VarC = $varB; for my $offsets ( @fields ) { substr $VarC, $offsets->[0], 0, ""; substr $VarC, $offsets->[1], 0, ""; } print $VarC; ' Thsi is the widl cat