in reply to Ksh style select menus in perl
Here's how one might achieve the equivalent in perl:
If you want looping, you can add that yourself.my @menu = ( "Go left", "Go right" ); for my $i ( 0 .. $#menu ) { print $i+1, ") $menu[$i]\n"; } print "?"; $_ = <>; ($_) = /^(\d+)/; # extract just the digits, if any. $_--; # because the menu as displayed in 1-based. # now do whatever you want with the number in $_ and # the full text of the selected menu item in $menu[$_].
hth, hand.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Ksh style select menus in perl
by jdporter (Paladin) on Apr 27, 2005 at 17:39 UTC |