Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Menu's in perl

by Anonymous Monk
on Aug 08, 2005 at 01:26 UTC ( [id://481761]=perlquestion: print w/replies, xml ) Need Help??

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

I need a script that I can run like a menu.

Here is the setup. A user logs in, there shell is set to some perl script. That perl script gives them lots of options, each option runs another perl script. Is there any way to create a simple menu setup? A cpan module maybe?

Replies are listed 'Best First'.
Re: Menu's in perl
by chester (Hermit) on Aug 08, 2005 at 03:14 UTC
    There may be a better module, but Term::Prompt has an option for building a menu. It handles parsing input, making sure the user input a valid menu choice, taking multiple selections, etc. etc. Maybe something like this (pretty much taken straight from the module's documentation):

    use warnings; use strict; use Term::Prompt; my %option = ( 1 => sub { system('~/script1.pl') }, 2 => sub { system('~/script2.pl') }, 3 => sub { system('~/script3.pl') }, 4 => sub { exit }, ); my $result; while(1) { $result = prompt("m", { prompt => 'Pick an option', title => 'Menu', items => [ qw (Option1 Option2 Option3 Exit) ], order => 'down', rows => 4, cols => 1, display_base => 1, return_base => 1, accept_multiple_selections => 0, accept_empty_selection => 0, ignore_whitespace => 0, separator => '[,/\s]+' }, '1-3, 4 to exit', '1'); $option{$result}->(); }
Re: Menu's in perl
by davidrw (Prior) on Aug 08, 2005 at 02:08 UTC
Re: Menu's in perl
by fauria (Deacon) on Aug 08, 2005 at 09:27 UTC
    I have used Term::ANSIMenu in a couple of projects. Its easy to use, and works great.
Re: Menu's in perl
by dorward (Curate) on Aug 08, 2005 at 09:26 UTC

    Log in where?

    To a console? A couple of solutions have been posted already.

    To a GUI? Perhaps Tk or Wx.

    To a website? CGI::Application and Catalyst suggest themselves.

Re: Menu's in perl
by fizbin (Chaplain) on Aug 08, 2005 at 10:18 UTC
    Note that writing this in perl may not be your best option - you may want to look into the program pdmenu
    -- @/=map{[/./g]}qw/.h_nJ Xapou cets krht ele_ r_ra/; map{y/X_/\n /;print}map{pop@$_}@/for@/
Re: Menu's in perl
by bradcathey (Prior) on Aug 08, 2005 at 11:58 UTC

    Maybe I'm stating the obvious, but how about HTML (maybe with HTML::Template) and CGI? Unless, of course, this not a Web app.


    —Brad
    "The important work of moving the world forward does not wait to be done by perfect men." George Eliot

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://481761]
Approved by rob_au
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (3)
As of 2024-04-25 05:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found