[EMAIL PROTECTED] schrieb am 2001-05-31, 18:30:
> Hi gurus,
> In http://www.cpan.org/doc/FMTEYEWTK/is_numeric.html, ( Is it a
> number? ), Tom Christiansen writes:
>
>----------------------------------------------------------------------------------------------
> If you do care about getting 0's, then do this:
> do {
> print "Number, please: ";
> $answer = <STDIN>;
> if ($answer == 0 && $answer ne '0') {
> print "Bad number\n";
> }
> } until $answer;
>
>----------------------------------------------------------------------------------------------
>
> I tried this with ActiveState perl version 5.005_03. I entered 0 and got a
> bad number. After thinking awhile, I chomped the $answer. This works for
> 0,
> ( i.e. No "Bad number message" and the loop repeats ). I think we need a
> chomp there ( so instead of '0\n' ne '0', it is '0' ne '0' ). Is it so or
> am I missing something?
I'm thinking about what it is doing
...
If you enter a number, it exits, if you enter a zero it gives you a
"Bad number", as it is if you enter some non-digits.
So, what is a number???
Obviously zero is no number, that is all this script is doing, checking
your input, if it is a number.
$ dountil.pl
Number, please: 123
Siebenschlaefer@LORELEY ~/script
$ dountil.pl
Number, please: 0
Bad number
Siebenschlaefer@LORELEY ~/script
$ dountil.pl
Number, please: 478
Siebenschlaefer@LORELEY ~/script
$ dountil.pl
Number, please: sdf
Bad number
-gph
--
=^..^=