in reply to ksh like menu in perl.

^P It shouldn't be too difficult to handroll this one (update: although now seeing it, I prefer the cdarke solution above actually).

^C something like (untested):

# cls => 1 # option to clear tty screen # opt => [ letter, text, coderef, ... ] # menu choices # to make a code ref assign sub { your-code } to the array element # in this way assign handling code to each choice letter sub GetChoice { my %opt = @_ or die; # using hash-style parameters $opt{ cls } ||= 0 and system 'cls'; my $maxchoice = $#{ $opt{ opt } } - 2; my %coderef = {}; my $done = 0; do { for ( my $choice = 0; $choice <= $maxchoice; $choice += 3 ) { ( ref( $opt{ opt }[ $choice + 2 ] eq 'CODE' ) or die "not a code reference"; $coderef{ $opt{ opt }[ $choice ] } = $opt{ opt }[ $choice + 2 +]; my $text = $opt{ opt }[ $choice + 1 ]; chomp $text; $text .= "\n\n"; print $opt{ opt }[ $choice ] . "\t$text"; } print "Enter option code: "; my $input = <>; if ( $input ~= /^(\w)/ ) { if ( defined( $coderef { $1 } ) ) { $coderef -> { $1 }(); $done = 1; } } unless( $done ) { $opt { cls } && system( 'cls' ); warn "Invalid option code $input"; } } until ( $done ); }
__________________________________________________________________________________

^M Free your mind!

Key to hats: ^I=white ^B=black ^P=yellow ^E=red ^C=green ^M=blue - see Moron's scratchpad for fuller explanation.