On Thu, Apr 11, 2002 at 08:06:14AM -0700, Paul Makepeace wrote: > 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..)
15 chars: ($a^$b)=~y/\0// /prakash -- Prakash Kailasa <mailto:[EMAIL PROTECTED]> == 'Course, that doesn't work when 'a' contains parentheses. -- Larry Wall in <[EMAIL PROTECTED]> ==