# replace non alphanumeric characters with '' $name =~ s/\W//g; # replace '_' with '' because \W doesn't catch those $name =~ s/_//g;