Subject: | Use of uninitialized value $response in ord |
Hi,
A warning is emitted when you just hit enter, which is pretty annoying.
[patch attached]
$ perlMIO::Prompt -wE 'prompt -menu => [1..4],-default=>"";'
a. 1
b. 2
c. 3
d. 4
Show quoted text
> []
Use of uninitialized value $response in ord at /Users/bgursoy/.plenv/versions/5.26.0/lib/perl5/site_perl/5.26.0/IO/Prompt.pm line 589.
$ perl -MIO::Prompt -wE 'say for IO::Prompt->VERSION, $^V'
0.997004
v5.26.0
Subject: | warning.patch |
--- Prompt.pm.orig 2017-09-27 17:51:25.000000000 +0200
+++ lib/IO/Prompt.pm 2017-09-28 12:13:43.000000000 +0200
@@ -586,15 +586,24 @@
}
}
print {$OUT} "\n";
- my $selection = $data[ord($response)-ord('a')];
- $response = defined $response ? $val_for->($selection) : $response;
- if (defined $response && ref($response) =~ m/\A(?:HASH|ARRAY)\z/xms ) {
+ my $selection;
+
+ if ( defined $response ) {
+ $selection = $data[ord($response)-ord('a')];
+ $response = $val_for->($selection);
+ }
+
+ if ( defined $response
+ && defined $selection
+ && ref($response) =~ m/\A(?:HASH|ARRAY)\z/xms
+ ) {
$response = _menu($IN, $OUT, {%{$flags}, -menu=>$response}, "$selection: ");
if (defined $response && $response eq "\e") {
print {$OUT} "\n", @prompt if -t $IN;
next;
}
}
+
return _tidy($response);
}
}