A very simple way to remove everything except wanted chars from the user input. Alternatively check if user input contains something besides wanted chars.
(next step: use the tr UTF-8 support to clean UTF-8 input)
# Remove everything except a-z,0-9
tr/a-z0-9//cd;
# Print a warning if something besides a-z,0-9 is found
print "Warning ! Did you mean '$_'? "
if ( tr/a-z0-9//cd ) ;
# Clarification [2001-5-29]: this is just an example,
# modify the allowed chars set at your will.
# You may also want to lowercase the input with 'lc' or
# 'tr/A-Z/a-z/';