Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

Re: Challenge - Creative Way To Detect Alpha Characters

by premchai21 (Curate)
on Sep 15, 2004 at 23:13 UTC ( #391322=note: print w/replies, xml ) Need Help??

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); }

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://391322]
[choroba]: my best run so far
[erix]: I think they build a portaging installation for yachts here not so long ago - lemme google it
[erix]: choroba ah, you should have sprinted 7 s off that :)
[erix]: (but then there's always a next (im)possible goal)
Corion avoids running by starting on time
[choroba]: my phone showed me 1 hour 10 km which was my goal, it changed a bit after uploading to the website
[erix]: choroba I believe you ;)

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (1)
As of 2017-05-24 12:52 GMT
Find Nodes?
    Voting Booth?