Subject: | When @ARGV is localized, prompt does not prompt a prompt. |
Date: | Sun, 18 Nov 2018 16:52:22 +0100 |
To: | bug-IO-Prompt [...] rt.cpan.org |
From: | Gilles LAMIRAL <gilles [...] lamiral.info> |
Hi Damian,
Here is a little script showing an issue when @ARGV
is localized: IO::Prompt::prompt() does not prompt a prompt.
I searched in the source where it could be fixed.
Not found, too complex for me!
(I felt like an elephant in a Chinese store)
#!/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('Say something: ');
return $input ;
}
--
Au revoir,
Gilles Lamiral. France, Baulon (35580)
mob 06 19 22 03 54
tel 09 51 84 42 42