in reply to how to manage a large console menu
%choices = ( "system1" => "hostname_for_system1", "system2" => "hostname_for_system2", "system3" => "hostname_for_system3", ); #displays the menu sub menu { my $i = 0; my @sorted_keys = sort(keys %choices); print "Please pick which system you wish to FTP to:\n"; foreach $key (@sorted_keys) { printf "%3d) %s\n", ++$i, $key; } chomp(my $option = <>); return $choices{$sorted_keys[$option-1]} if $option >= 1 && $optio +n <= scalar(@sorted_keys); } $pick = menu; print "system picked = $pick\n"; # do_something_with($pick);
|
|---|