Forgive me if i am not 100% clear on my question, its Monday morning and i have not had my first cup of coffee yet ;)

I have a script i am writing that will run in a console. In one of the parts of the script I have a menu where a user will need to choose which system he wants to ftp processed files to. The menu in question is a list of 40+ systems in it and I am wondering if there was a cleaner way of displaying all the options in the console that just doing a whole mess load of print/switch statements. I have found this makes it a pain in the butt to go back and make any changes to the list (ie adding a new system) to the list.

here is some example code of how i am displaying it

#displays the menu sub menu { print "Please pick which system you wish to FTP to:\n"; print "1.) system1\n"; print "2.) system2\n"; etc.. etc.. chomp(my $option = <>); } #switch statment using switch::perlish #hostnames changed to protect the innocent while ($option ne "q") { menu(); switch $option, sub { case '1', sub {dftp("hostname_to_system1")}; case '2', sub {dftp("hostname_to_system2")}; etc etc case 'q', sub {exit}; }

Thanks for the help!


In reply to 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.