On 20 Apr 2004 at 20:48, Craig S. Cottingham wrote:

> On Tue, 2004-04-20 at 19:26, Bernie Cosell wrote:
> > On 20 Apr 2004 at 19:57, [EMAIL PROTECTED] wrote:
> > > We want to find out the first position $n at which strings $x and $y
> > > differ....
> > 
> > How about [not golfing so the code is clearer]:
> >     my $diff = $x ^ $y;
> >     my ($len) = $diff =~ /^([\0])[^\0]/ ;
> >     return uhdef if not defined $len ;
> >     return length $len;'
> 
> I couldn't get that to work.

Really?  I cleaned it up a bit and it seems to work fine:

sub diff
{   my $diff = $_[0] ^ $_[1];
    my ($len) = $diff =~ /^([\0]*)[^\0]/ ;
    return undef if not defined $len ;
    return length $len;
}

  /Bernie\

-- 
Bernie Cosell                     Fantasy Farm Fibers
mailto:[EMAIL PROTECTED]     Pearisburg, VA
    -->  Too many people, too few sheep  <--       



Reply via email to