On 4/7/11 Thu Apr 7, 2011 10:48 AM, "Balaji krishnan" <balaji.r.krish...@gmail.com> scribbled:
> Hi folks > > I have been using shell script for my admin work and recently decided to use > perl fo all my automation. So proud I did that. > > Quick question: I have been using "Select" function in shell to present > menu to users. Do we have a "select" equivalent in perl? Or if I have a list > of names in an array what is the best way to present them in a menu and > prompt the user to select one from the list? I use the print statement to present the list of items with a number, then print a prompt (without a newline). Then use statements of the type my $ans = <STDIN> chomp($ans); to get a response from the user. You can then test that response and act accordingly. Simplest approach is to number your choices and get a number from the user. A blank line or zero can be do nothing (it's always a good idea to have a no operation choice). -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/