in reply to Stdin for just numbers.
Hello programmercarlito,
Actually, the first two paragraphs are not working correctly as you believe. There are three problems. First, after $startAmount = <stdin> the variable $startAmount always ends in a newline character (or character sequence), so it is never the empty string. You need to chomp it before you test it.
Second, == compares numbers, but "" is a string. You should use eq instead: while($startAmount eq ""){.
Third, testing for an empty string won’t tell you whether the user has input a valid number. See How-do-I-determine-whether-a-scalar-is-a-number-whole-integer-float of perlfaq4.
Hope that helps,
| Athanasius <°(((>< contra mundum | Iustus alius egestas vitae, eros Piratica, |
|
|---|