if ($answer =~ /\D/) { ## if answer has any non-digits print "Please enter a number only\n"; next; }