Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

aitap's scratchpad

by aitap (Deacon)
on Jul 08, 2012 at 10:20 UTC ( #980565=scratchpad: print w/ replies, xml ) Need Help??

$ cat /tmp/1.pl #!/usr/bin/perl use warnings; use strict; use IO::Prompter 'prompt'; my %actions = ( display => sub { print_table(); }, learn => sub { learn_message(); }, quit => sub { exit; }, ); while (my $mode = prompt 'What to do now?', -menu => [ keys %actions ] +) { compute_scores(); $actions{$mode}->(); } $ perl /tmp/1.pl What to do now? a. quit b. learn c. display Enter [a-c]:
How it works:
  • What to do now? a. quit b. learn c. display
  • I type "a" and get "p"
  • I get surprised and press Enter
  • Enter [a-c]:
  • I type some other buttons (no matter if they are "abc" or something completely different)
  • Enter [a-c]: rompt
  • I press Enter again
  • Enter [a-c]:
  • Prompt remains silent forever
Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (10)
As of 2015-08-05 06:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The oldest computer book still on my shelves (or on my digital media) is ...













    Results (80 votes), past polls