in reply to force user to only enter numbers

Can you show us what you have so far?

If you don't have anything yet, you might consider building a loop that reads from STDIN, and then checks the string for non-numeric characters with a regular expression. Don't forget to chomp! Once the string is in the format you want, leave the loop and process it however you want.

Replies are listed 'Best First'.
Re^2: force user to only enter numbers
by adroit (Initiate) on Sep 02, 2011 at 16:12 UTC
    This is what I have tried
    print "Enter a number\n"; $num = <STDIN>; if ($num < 0) { print "please enter a number that is between 0 and 9 \n"; $num = <STDIN>; } #Get input +from the keyboard for($i=1;$i<=$num;$i++) #For loop to repeat a + set of statements until a condition is met { print $i; } print "Press any key to exit"; $key = <STDIN>; #End of Program