On Thu, Apr 11, 2002 at 05:12:08PM -0400, Ronald J Kimball wrote: > On Thu, Apr 11, 2002 at 05:06:28PM -0400, Prakash Kailasa wrote: > > On Thu, Apr 11, 2002 at 05:03:53PM -0400, Jeff 'japhy' Pinyan wrote: > > > On Apr 11, Prakash Kailasa said: > > > > > > >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, > > > > > > > >($a^$b)=~y/\0// > > > > > > That isn't helpful, though -- that merely gives a count of how many > > > characters were the same between the two. We need the position of the > > > first difference. > > > > Hmm, wasn't the example given by Paul (original poster) giving the > > same value? > > > > ($a ^ $b) =~ /^(\0*)/ && length $1 > > Whether they give the same value depends on the values of $a and $b. Try > it with $a = 'abcdef' and $b = 'abCdef', for example.
Yep. ($a^$b)=~y/\0// doesn't work in this case. I overlooked this possibility. However, my assumption that position numbering was zero-based seems valid for Paul's expression too. That was the reason I was comparing the two. Anyway, that's a moot point now that it has been shown that my expression is not correct. > Ronald Thanks, /prakash -- Prakash Kailasa <mailto:[EMAIL PROTECTED]> == If you're going to define a shortcut, then make it the base [sic] darn shortcut you can. -- Larry Wall in <[EMAIL PROTECTED]> ==
