Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: Challenge - Creative Way To Detect Alpha Characters

by CombatSquirrel (Hermit)
on Sep 13, 2004 at 18:07 UTC ( [id://390627]=note: print w/replies, xml ) Need Help??


in reply to Challenge - Creative Way To Detect Alpha Characters

The plain old C way:
#!perl use strict; use warnings; sub contains_alpha($) { my ($ord_a, $ord_z, $ord_A, $ord_Z) = map ord, qw/a z A Z/; for (split //, $_[0]) { $_ = ord $_; return 1 if ($ord_a <= $_ and $_ <= $ord_z) || ($ord_A <= $_ and $_ <= + $ord_Z); } return 0; } for (<DATA>) { chomp; print "'$_' " . (contains_alpha $_ ? 'contains' : 'does not contain +') . " standard alphabet characters\n"; } __DATA__ Hi 123456789o 1234567890 xAFCE3 xAFCEA ... --- ... .s. -o- .s.
Not really creative, though...
CombatSquirrel.

Entropy is the tendency of everything going to hell.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://390627]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (3)
As of 2024-04-20 01:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found