prompt in debug.

  • daddmac

    daddmac - 2013-03-05

    i'm using Eclipse Juno Service Release 1.  I'm a perl noob, but have experience with other languages and platforms. 

    I'm trying to capture user input with the following code:
    #!/usr/bin/perl -w
    use v5.12;
    use IO::Prompter;

    say "i got this far.";

        my $selection
            = prompt 'Choose wisely…'; #, -menu => {
    #                wealth => ,
    #                health => ,
    #                wisdom => ,
    #          }, '>'

    say $selection;

    When I run the script, i see "i got this far.", and then nothing.  If I click on the Eclipse/EPIC console, type text, and press enter then the text is captured and written to the console like this:
    i got this far.

    Why isn't "Choose wisely…" being written to the console? 


  • Jan Ploski

    Jan Ploski - 2013-03-05

    "IO::Prompter exports a single subroutine, prompt, that prints a prompt (but only if the program's selected input and output streams are connected to a terminal),"

    I guess that's the reason. Eclipse's Console view displays stdin/out/err streams, but does not emulate a terminal.

  • daddmac

    daddmac - 2013-03-05

    Thanks jploski! 

    Should I look for:
    -> a way to connect the stream (stdio?) to the terminal.
    -> a different pm.
    -> a different ide more suited to my level of perl experience.
    -> a way to run the code in a console?  (activeperl on win 7)

    Any advice, instruction, and/or links are appreciated. 

  • daddmac

    daddmac - 2013-03-05

    like i said, i'm a noob to perl  i found the answer: just invoke the script on the windows command line and the application association with the "pl" extension will cause it to call perl to run it. 

    Thanks for your help jploski! 

  • Jan Ploski

    Jan Ploski - 2013-03-05

    You can't connect the stream to terminal in Eclipse/EPIC as there is no terminal.
    You probably don't need IO::Prompter specifically. You could just prompt for input yourself with print. Watch out for output buffering though (read about the special variable $| which controls this). Generally, when you write scripts it's usually a better idea to get input through command-line arguments anyway and not to prompt interactively.
    You can also keep IO::Prompter and run your Perl scripts from the command prompt or through "External Tools", but that sucks (you can't then easily debug with EPIC, for example).


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks