in reply to Text Menu Not Looping on CR/LF

Why not just check if the answer in in %menu_selection, and exit the loop only then? Something like:
while (1) { print <<EOF; Please select one of the following locations: 1.) Option 1.... 2.) Option 2.... 3.) Option 3.... EOF print "Selection: "; chomp(my $answer = <>); if ($menu_selection{$answer}) { print $menu_selection{$answer}, "\n"; last; } }

Replies are listed 'Best First'.
Re^2: Text Menu Not Looping on CR/LF
by ritz303 (Novice) on May 02, 2011 at 16:56 UTC

    Thanks, JavaFan! That worked. It makes complete sense, now that I think about it. Sometimes, I make my code more complicated then it should be.