Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: While loop

by mephit (Scribe)
on May 14, 2002 at 19:59 UTC ( [id://166563]=note: print w/replies, xml ) Need Help??


in reply to While loop

my $input = ''; until (($input =~ /^yes/i) or ($input =~ /^no/i)) { print "Please Enter Yes or No: \n"; chomp($input = <>); printf "'%s' entered for system\n", $input;
That works. It'll echo every value entered, which you didn't ask for, but it will also prompt for "yes" or "no" after every 'incorrect' input. Why patterns instead of eq? Easier to customize, IMO, in case you want to allow for different case (with the /i, as above), or just allow for 'y' or 'n,' or whatever. HTH

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://166563]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (4)
As of 2024-04-25 23:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found