in reply to Guess That Number
pretendeavor, your update isn't doing what toolic meant!
if ($answer !~ /\D+/) { ## if answer doesn't have any non-digits print "Please enter a number only\n"; ## Really? next; }
when you want
if ($answer =~ /\D/) { ## if answer has any non-digits print "Please enter a number only\n"; next; }
the character escape \D includes '-' the minus sign hence the positive integer comment. With character classes, capitalisation usually means the opposite (i.e. \d = all digits, \D all non-digits. The '+' sign means 'one or more matches' not positive! See perlre.
Other than that I like it! Got to get the kids started early!!
|
|---|