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

Hello Monks! I am asking for your infinite wisdom again.

I am working in a program where the user selects some options. Based in the selections he gets some output and based in that output he enters some data, and based in the data another output appears and he can select an option and so on...

What I am doing is basically a do-while loop. At the end of the loop, some if-else conditions are processed, so the loop executes again or another do-while loop is executed.

Do you know of some procedure or something like a pragma to build interactive CLI programms?

Any help is appreciated!

Replies are listed 'Best First'.
Re: Interactive program
by davido (Cardinal) on Jun 26, 2012 at 00:07 UTC

    Maybe it's late in the day for me, but I'm having a little difficulty parsing your question. Most of what you're talking about is just "programming", so I think you're asking about good ways to prompt for user input.

    For taking user input, I kind of like IO::Prompt::Tiny; it's simple to use, and is based on the prompt() function built into ExtUtils::MakeMaker. The one caveat is that it has a dependency on Capture::Tiny, which is also a really convenient module, but has a few FAILS on Win32 (and more PASSes). That may or may not be an issue for you.

    use IO::Prompt::Tiny qw( prompt ); # Prompt with a default of vanilla. my $input = prompt( 'Please enter your ice cream preference', 'vanilla +' ); print "So....you like $input ice cream. Freud would love this revelat +ion.\n";


Re: Interactive program
by sauoq (Abbot) on Jun 25, 2012 at 23:57 UTC
    Do you know of some procedure or something like a pragma to build interactive CLI programms?

    By "pragma" I wonder if you don't just mean a module...

    See Term::ReadLine maybe.

    "My two cents aren't worth a dime.";
Re: Interactive program
by ~~David~~ (Hermit) on Jun 26, 2012 at 16:53 UTC
    To me, it sounds like you are looking for an event driven interactive program with option selection, etc. I usually use a GUI for these type of needs, and I always use Tk.
Re: Interactive program
by oldwarrior32 (Sexton) on Jun 26, 2012 at 23:48 UTC

    I was just looking for some "good practices" making interactive programming. Thanks for your help.