The task is to find the first differing character given two strings.
There is one obvious solution walking along using substr,

  for ($i = 0; substr($foo, $i, 1) eq substr($bar, $i, 1); $i++) {}

#london.pm quickly came up with,

  ($a ^ $b) =~ /^(\0*)/ && length $1

with the possible caveat that this could be wasteful for large, and
especially early differing strings. It is nice that it's an expression
though.

Any other ways, golfed or otherwise?

Paul (*sure* this has come up before, somewhere..)

-- 
Paul Makepeace ....................................... http://paulm.com/

"What is ket? A sloppy kiss from your great aunt."
   -- http://paulm.com/toys/surrealism/

Reply via email to