if ( $vlan_name =~ m|^\w[\w-]*$| ){ # Name complies with : # * At least one char # * Starts with a letter, number or underscore # * Contains only alpha, num, underscore, hyphem }else{ # Complain about non-compliant name } #### if ($vlan_number =~ m|^\d+$|) { # Compliant - numeric only }else{ # Something Not completely numeric - display error. }