http://www.perlmonks.org?node_id=350569


in reply to Re: fast bit twiddling
in thread fast bit twiddling

There's a mistake here, since the eq operator has an higher precedence than the comma.
The sub should be written this way:
sub buk2{ my $s = shift; substr($s, $_-1, 1) eq substr($s, $_, 1) and return for @_; return 1; }
Oddly enough, after the correction above this solution proves to be the fastest (probably because it reaches the first return more frequently.)
See here for the updated benchamark results.

Cheers, Emanuele.