How can I build a simple menu in Perl?

前端 未结 6 1118
野的像风
野的像风 2020-12-11 20:23

I\'m working on a Perl script that requires some basic menu functionality. Ultimately I would like each menu to have a few options and then the option to either return to th

6条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-11 21:00

    I have found this old module without any perldoc in my perl modules... Please, give it a try...

    #!/usr/bin/perl
        BEGIN { $Curses::OldCurses = 1; }
        use Curses;
        use perlmenu;
        &menu_init(0,"Select an Animal"); # Init menu
    
        &menu_item("Collie","dog"); # Add item
        &menu_item("Shetland","pony"); # Add item
        &menu_item("Persian","cat"); # Add last item
    
        $sel = &menu_display("Which animal?"); # Get user selection
    
        if ($sel eq "dog") {print "Its Lassie!\n";}
    

提交回复
热议问题