A magical variable is never SvPOK, but only SvPOKp. The code for
checking whether a duplicatee is a numeric file descriptor was only
checking SvPOK. So a regular variable containing a fileno-as-a-string
would work, such as the $a below, as would a stringified magical vari-
able ("$1"), but not $1 itself.
$ echo foo | perl -le '$a = "0"; open a, "<&", $a; warn <a>'
foo
$ echo foo | perl -le '"0" =~ /(.)/; open a, "<&", $1; warn <a>'
Can't use an undefined value as filehandle reference at -e line 1.
$ echo foo | perl -le '"0" =~ /(.)/; open a, "<&", "$1"; warn <a>'
foo
SvPOK variables are also SvPOKp, so checking only the latter suffices.
}
while (isSPACE(*type))
type++;
- if (num_svs && (SvIOK(*svp) || (SvPOK(*svp) && looks_like_number(*svp)))) {
+ if (num_svs && (
+ SvIOK(*svp)
+ || (SvPOKp(*svp) && looks_like_number(*svp))
+ )) {
fd = SvUV(*svp);
num_svs = 0;
}
use warnings;
use Config;
-plan tests => 120;
+plan tests => 121;
my $Perl = which_perl();
# used to try to open a file [perl #17830]
ok( open(my $stdin, "<&", fileno STDIN), 'dup fileno(STDIN) into lexical fh') or _diag $!;
+
+ fileno(STDIN) =~ /(.)/;
+ ok open($stdin, "<&", $1), 'open ... "<&", $magical_fileno',
+ || _diag $!;
}
SKIP: {