in reply to How do I keep anything other than alphanumeric out of a variable?

The right tool for character classes is tr///, not s///:

$user_name =~ tr/0-9a-zA-Z//dc;
(You can add the underscore character, or any others you like, of course.)

If you wanted the username to look like a valid Perl identifier (i.e., begin with a letter, then alphanumerics + underscores), you would then want to strip off the leading non-letters:

$user_name =~ s/^[^a-z]*//i;