in reply to String matching idea
Update: no code was requested, so using the spoiler tag:
my $xor = $s1 ^ $s2; $xor =~ /[^\0]/g; my $prefix_length = pos($xor) - 1;
If your strings only contain "a" and "b", you can use
index $s1 ^ $s2, "\03"
directly, because "\03" eq ('a' ^ 'b').
|
|---|