Subject: | Options -in/-out=>*FH (and -stdio) seem broken |
For IO::Prompter v0.002000, options -in=>*FH, -out=>*FH (and hence
-stdio) to prompt() no longer seem to work.
Eg
--------------------
use IO::Prompter;
my $n = prompt -num, -in=>*STDIN, 'Enter a number';
say "You entered: $n";
--------------------
results in the error:
prompt(): Unacceptable value for -in (expected valid filehandle or
filename)
I'm happy to use -in=>\*FH etc (which work) if necessary, but -stdio
will still be broken.
A possible patch is just
--------------------
--- Prompter.pm.orig 2012-05-08 12:09:32.679986598 +0800
+++ Prompter.pm 2012-05-08 12:05:55.030907337 +0800
@@ -88,12 +88,12 @@
# Work out where the prompts go, and where the input comes from...
my $in_filehandle = $opt_ref->{-in} // _open_ARGV();
my $out_filehandle = $opt_ref->{-out} // qualify_to_ref(select);
- if (!ref $in_filehandle) {
+ if (!ref $in_filehandle && ref(\$in_filehandle) ne "GLOB") {
open my $fh, '<', $in_filehandle
or _opt_err('Unacceptable', '-in', 'valid filehandle or
filename');
$in_filehandle = $fh;
}
- if (!ref $out_filehandle) {
+ if (!ref $out_filehandle && ref(\$out_filehandle) ne "GLOB") {
open my $fh, '>', $out_filehandle
or _opt_err('Unacceptable', '-out', 'valid filehandle or
filename');
$out_filehandle = $fh;
--------------------
Thanks,
David