in reply to Re^2: Substring Distance Problem
in thread Measuring Substrings Problem
This said, I find the final computation quite elegant and istructive - I wouldn't have thought of XORing letters even in 100 years.
I had the same reaction as yours when I first encountered the "infamous xor trick" (in this case to find the first position at which two strings differ, or equivalently, the length of the longest common prefix):
Way cool, though it works as written only if the characters are 1 byte long.$a = "foobar"; $b = "foobAr"; ($a ^ $b) =~ /^(\0*)/ and print length $1; __END__ 4
There's always to learn, luckly, provided I'll be able to remember it when I'll need :)
Yep, that's the rub.
the lowliest monk
|
|---|