imapsync/W/learn/bug_io_prompt_local_ARGV
Nick Bebout 852d9695d6 1.920
2019-07-02 18:20:46 -05:00

38 lines
878 B
Perl
Executable file

#!/usr/bin/perl
use strict;
use warnings;
use IO::Prompt;
# The defect is when used with a pipe, like the following on the command line example,
# prompt() does not print the prompt string 'Say something: '
# however the variable @ARGV is locally empty.
# The output is then only:
#
# $ echo bla bla bla | ./bug_io_prompt_local_ARGV param1 param2
# ARGV are param1 param2
# You said: bla bla bla
# I tried also
# prompt( \*STDOUT, 'Say something: ');
# The behavior is ok without the pipe:
# ./bug_io_prompt_local_ARGV param1 param2
print "$IO::Prompt::VERSION\n" ;
print "ARGV are @ARGV\n" ;
my $input = get_stdin();
print "You said: $input\n" ;
sub get_stdin
{
local(@ARGV) ;
my $input = prompt(
-prompt => 'Say it: ',
-echo => '*',
-newline => "\nGot it\n"
) ;
return $input ;
}