my $LENGTH = 0; while (1) { print "Enter the length!"; "\n"; chomp ($LENGTH = <>); # checking for non-numeric characters if ($LENGTH =~ /\D/){ print "\nPlease enter a number\n"; next; } last if 0 <= $LENGTH and $LENGTH <= 99.99; }