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