# original if($view_tag =~ m/[^A-Za-z0-9_\-\.]/) { # corrected if($view_tag =~ m/^[A-Za-z0-9][\w.-]*/) { # to anchor the match at the beginning, # the ^ comes immediately after the first /: m/^[A-Z ... # match the first character [A-Za-z0-9] # matching subsequent characters: [\w.-]* # \w is the same as [A-Za-z0-9_] # . does not need to be escaped when inside brackets # put - last inside brackets, otherwise it may indicate a range # the quantifier * matches 0 or more instances of the characters