On Apr 11, Jeff 'japhy' Pinyan said:

>On Apr 11, Paul Makepeace said:
>
>>The task is to find the first differing character given two strings.
>
>You can get a little niftier if you're using Perl 5.6:
>
>  ($a^$b)=~/^\0*/&&$+[0]

Duh.  Remove the ^ and change the && to * and you save two chars:

  ($a^$b)=~/\0*/*$+[0]

The regex always succeeds -- thus, always returns 1.

-- 
Jeff "japhy" Pinyan      [EMAIL PROTECTED]      http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
** Look for "Regular Expressions in Perl" published by Manning, in 2002 **
<stu> what does y/// stand for?  <tenderpuss> why, yansliterate of course.
[  I'm looking for programming work.  If you like my work, let me know.  ]

Reply via email to