# Just add any other valid characters after the \w if($password =~ /[^\w]/) { # invalid character supplied }