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

I am attempting to collect information based upon prompts generated within the script. Using perl-5.16.3 on MacOSX this code works perfectly. If I attempt to use it on a windows machine with Activeperl or Strawberry perl (both also 5.16.3) installed it never returns after entering the string and hitting the enter key.

Any assistance or alternative would be appreciated. Please keep in mind that in the original script I am asking for a password at one of th prompts so proper obfuscation needs to be available.

Here is the code I am using for the prompt in one of the entries. It must not be a empty string, when I enter something at the prompt it doesn't even print out the value or an error or anything.

use 5.14.0; use strict; use warnings; use IO::Prompter [-v]; my $string=""; do { $string = prompt("Input a string:"); print "$string\n"; } until ($string ne "");

Replies are listed 'Best First'.
Re: IO::Prompter not returning from Enter keypress using Activeperl
by davido (Cardinal) on Jun 19, 2013 at 01:23 UTC

    Which version of IO::Prompter? I see test failures on at least one Windows system in some of the earlier versions. The most recent version (0.004005) seems to have a more successful smoke test record, but I see from its change log that the most recent version disables interactive testing on Windows platforms, so it's possible a problem is being missed by the tests.

    IO::Prompt::Tiny is designed to be highly portable, as it's based on ExtUtils::MakeMaker's prompt, which must be portable. Your simple functionality would be perfectly fine with IO::Prompt::Tiny. IO::Prompt::Hooked is based on IO::Prompt::Tiny, and should be as portable, but might even simplify your logic a little:

    use IO::Prompt::Hooked; my $string = prompt ( message => 'Input a string:', validate => sub { q{} ne shift } );

    ...or even...

    my $string = prompt ( message => 'Input a string:', validate => qr/./ );

    Do make sure that the environment variable PERL_MM_USE_DEFAULT is not set.


    Dave