suekawar has asked for the wisdom of the Perl Monks concerning the following question:

Hi all, I am wondering if I can do that . I am trying to make my script feed (select options from another script that contains a menu). For example, when you run menueScrip.pl , you will have somthing like :
welcome the the menue 1. delete file 2. makdir 3. do list 4. quit Please enter your selection:
what my script will do is run that menu script then start making selection based on the value i pass to my script fro example i run my script as follow myscript.pl -o 1 which will select 1 . I am just trying to see if there is a way to do that , just how to control that menu from another script. please let me know or give me a hint on doing it .. thanks

Replies are listed 'Best First'.
Re: feeding a menu from script
by jobber (Sexton) on Feb 06, 2003 at 17:31 UTC
    Hello, Im not sure if this is what your looking for, but you may be looking for something similar to expect. expect allows you to feed input based on the ouput of another comsole program. So you could output a 1 to the screen after you see the string "Please Enter your selection";
    use Expect; $lis = Expect -> spawn ("/bin/yourprog"); $lis -> expect (30, "Please Enter your selection:"); print $lis "1\r";

    hope this helps
Re: feeding a menu from script
by denisem (Initiate) on Feb 10, 2003 at 11:37 UTC
    see if this will help you:

    $menu = <STDIN>; &delete_files if($menu == 1); &makdir if($menu == 2); # and so on. sub delete_files { # stuff goes here }

    dont know is it what you want.