diff options
author | Father Chrysostomos <sprout@cpan.org> | 2011-12-24 23:27:30 -0800 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2011-12-24 23:31:35 -0800 |
commit | 204263bc1eb63f1dfd6180c05dca8cec2c319504 (patch) | |
tree | caf6a3d6d37d16d94ed06f33320b39ba4b5d209b /t | |
parent | 01e8a1a6f52deee45aadeddbd49c199f4048b262 (diff) | |
download | perl-204263bc1eb63f1dfd6180c05dca8cec2c319504.tar.gz |
select() sometimes returns invalid string
The return value from select() is sometimes a string, and sometimes a
globref. It was originally always a string, but typeglobs not to be
found under their names in their stashes started being returned as
references in 5.002 beta 1 (4633a7c4b). The logic is a little faulty,
though, as sometimes the name that is returned cannot be used to find
the glob:
$ perl -le '
open "foo::bar", ">/dev/ttys009";
select foo::bar;
my $handle = \*foo::bar;
my $stash = \%foo::bar;
*foo:: = *bar::;
print "hello";
select select;
print "hello" or warn $!
'
Bad file descriptor at -e line 9.
In this example, /dev/ttys009 is another terminal window. "hello"
only appears once, not twice.
Diffstat (limited to 't')
-rw-r--r-- | t/op/select.t | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/t/op/select.t b/t/op/select.t index 7c27f6ff25..06caf1ddfd 100644 --- a/t/op/select.t +++ b/t/op/select.t @@ -5,7 +5,7 @@ BEGIN { require './test.pl'; } -plan reverse 7; +plan reverse 8; open my $fh, "test.pl" or die "$0 unfortunately cannot open test.pl: $!"; @@ -17,3 +17,11 @@ is select, $fh, 'the ref returned references the right referent'; is select(STDOUT), $fh, 'select previous ref when setting to bareword'; is select, 'main::STDOUT', 'switching back to STDOUT'; is ref\select, 'SCALAR', 'and STDOUT is a plain string'; + +open foo::bar, "test.pl" or die "$0 sadly cannot open test.pl: $!"; +select foo::bar; +$handle = \*foo::bar; +$stash = \%foo::; +*foo:: = *bar::; +is select, $handle, + 'select returns ref for glob whose stash has been detached'; |