my $num = "123456"; unless ($num =~ /^\d{5,}/ && $num !~/\w/) { print p("Sorry, $num does not match the regex"); } else {print p("$num matched")};