in reply to Trouble Creating a Menu
If you want single key responses, see Re: Using File::Tail::select with STDIN? , where you don't need the Return key to capture a keystroke.
#!/usr/bin/perl -w use strict; my $question; my $computer; my @pc = qw(comp1 comp2 comp3 comp4 comp5); # Find out which computer to cold start system("clear"); do { print "Which computer would you like to cold start?\n"; print "1 - comp1 2 - comp2 3 - comp3 4 - comp4 5 - comp5\n"; $question = <STDIN>; chomp($question); } until ($question >= 1) & ($question <= 5); $question--; $computer = $pc[$question]; print "$computer\n"; print "Hit Return to continue\n"; <>; # wait for a newline
|
---|