in reply to check if string contains anything other than alphanumeric

You can negate the character class:

if ($string =~ m/[^a-zA-Z0-9]/){ print "The string contains non-alphanumeric characters"; }