As paulehr made a distinction between 'system1' and 'hostname_to_system1', it might be better to use a hash:
my %systems = ( system1 => 'hostname_to_system1', system2 => 'hostname_to_system2', ... ); my $choice = menu; dftp( $systems{$choice} ); # sub menu { my @choices = (sort keys %systems) print "Please pick which system you wish to FTP to:\n"; foreach my $i ( 0 .. $#choices ) { printf( "%2i.) %s\n", $i+1, @choices($i)); } # get input ... assuming in $option; if ( $option eq 'q' ) { exit; # or an abort routine to handle cleaning up } elsif ( defined( $choices[$option-1] ) ) { return $choices[$option-1]; } else { print "Unknown option.\nPlease try again\n"; goto &menu; # yes, goto. Please don't give me the 'goto is evil' + speach } }
(this of course assumes the whole 'roll your own' approach, and not using some of the text-based menu systems available in CPAN)
In reply to Re^2: how to manage a large console menu
by jhourcle
in thread how to manage a large console menu
by paulehr
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |