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
Based on this I assumed that the position numbering was zero-based, so
the value returned by the above expressions should give the position
of the first differing character.
/prakash
--
Prakash Kailasa <mailto:[EMAIL PROTECTED]>
==
When in doubt, parenthesize. At the very least it will let some
poor schmuck bounce on the % key in vi.
-- Larry Wall in the perl man page
==