in reply to while loop almost correct
use strict; use warnings; my @array = qw(a Grant b Yoda c Liberace d None); my %hash= @array; CHECK: print "Who's Buried in Grant's Tomb\n"; print <<ENDING; a. Grant b. Yoda c. Liberace d. None of the above. ENDING while(chomp(my $answer = <STDIN>)){ if(defined $hash{$answer}){ print "your Answer is \"$hash{$answer}\".\n"; print "Thank You.\n"; #do anything with the Answer.... exit; }else{ print "Please Pick a letter between A - D\n"; goto CHECK; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: while loop almost correct
by JadeNB (Chaplain) on Nov 17, 2009 at 20:38 UTC | |
|
Re^2: while loop almost correct
by irvson (Sexton) on Nov 17, 2009 at 23:28 UTC | |
|
Re^2: while loop almost correct
by irvson (Sexton) on Nov 18, 2009 at 16:25 UTC |