http://qs1969.pair.com?node_id=391322


in reply to Challenge - Creative Way To Detect Alpha Characters

Highly ASCII-specific, and inefficient, but perhaps mildly interesting. Appears to work, though no absolute guarantees are made of course. Using tr/// is kind of a wart, though, hmm.

sub contains_alpha { use bytes; my ($string) = @_; my $len = length($string .= ""); my @b = map{$string & (chr(1<<$_) x $len)} (0..7); tr/\x01-\xff/\x01/ for @b; my $result = (~$b[7]) & ($b[6]) & (($b[4] & ~($b[3] & (($b[1] & $b[0]) | $b[2]))) | ((~$b[4]) & ($b[3] | $b[2] | $b[1] | $b[0]))) ; $result =~ tr/\x00//d; length($result); }