my $length = 0; while (1) { print "Enter the length: "; chomp ($length = <>); # checking for non-numeric characters unless ($length =~ /^[\d.]+$/){ print "\nPlease enter a number\n"; next; } last if 0 <= $length and $length <= 99.99; print "It must be between 0 and 99.99\n"; }