in reply to Match alphamumeric and space

You left '0' out of your character class. Other than that it's fine. It would have been harder to leave out if you used [:alnum:] or even \d in your char class.

More a matter of completeness than an actual suggestion, you should know that tr/// can also be used for this. The /c modifier can be used to complement the search list. tr/// is sometimes faster than a regex.

This is equivalent to your example. (Well, almost. I allow '0' too.)

if ($string =~ tr/a-zA-Z0-9 //c) { # trigger error message. }

If you need to allow newlines and tabs, you can do that too.

if ($string =~ tr/a-zA-Z0-9 \t\n//c) { # trigger error message. }

Character classes like \d or [[:alpha:]] won't work with tr/// though.

-sauoq
"My two cents aren't worth a dime.";