in reply to RE: Re: Minor query
in thread Minor querry!!
All these loops are so long! Labels and status variables and chomping, oh my!
How about this:
{ print "Number?\n"; redo unless <STDIN> =~ /^\d+$/; }
Or, to save the value (which can be useful :)
{ print "Number?\n"; redo unless <STDIN> =~ /^(\d+)$/ and $number=$1; }
But my personal favorite would be simply:
print "Number?\n" while <STDIN> !~ /^\d+$/;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
RE: RE: RE: Re: Minor query
by merlyn (Sage) on Jun 25, 2000 at 16:58 UTC | |
by turnstep (Parson) on Jun 25, 2000 at 19:16 UTC |