Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: prompting a user for input

by perigeeV (Hermit)
on Nov 04, 2001 at 17:50 UTC ( [id://123183]=note: print w/replies, xml ) Need Help??


in reply to prompting a user for input

Here's some fun; reverse the string and the regex in the statement, eg.:

if ( "" =~ /^\Q$answer/i ) { default() } elsif( "YES" =~ /^\Q$answer/i ) { affirmative() } elsif( "NO" =~ /^\Q$answer/i ) { negative() }

Now the user can type "y", "ye" or "yes".

Or if you want you can build a case statement:

SWITCH: { $answer =~ /^yes|y$/ && do { affirmative(); last SWITCH; }; $answer =~ /^no|n$/ && do { negative(); last SWITCH; }; default(); }

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (2)
As of 2024-04-19 20:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found