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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.