in reply to Matching alphanumeric characters from urandom
In addition to the good answer about ord above, you also need to realize that m/[55-90]/ isn't doing what you want. A bracketed construct matches exactly one character, one of the ones in its range. For example, m/[78!]/ would match any of the characters 7, 8 or !, but not the whole string 78!. Similarly, m/[5-9]/ would match any one of the characters 5, 6, 7, 8, or 9, but a construct like m/[55-90]/ is just confusing.
If you want to check whether the character is ascii, you need to see if it's within the range you want. Perl lets you check the character directly, like so:
is a reasonable test, as long as you're sure your input is ASCII (it wouldn't work for EBCDIC, as an extreme example).if ($character >= 'A' && $character <= 'Z')
|
|---|