1#!./perl 2 3BEGIN { 4 chdir 't'; 5 require './test.pl'; 6} 7 8plan reverse 9; 9 10 11open my $fh, "test.pl" or die "$0 unfortunately cannot open test.pl: $!"; 12 13is select, 'main::STDOUT', 'select retval'; 14is select($fh), 'main::STDOUT', 'select retval when called with argument'; 15ok ref select, 'select returns ref for glob generated by open'; 16is select, $fh, 'the ref returned references the right referent'; 17is select(STDOUT), $fh, 'select previous ref when setting to bareword'; 18is select, 'main::STDOUT', 'switching back to STDOUT'; 19is ref\select, 'SCALAR', 'and STDOUT is a plain string'; 20 21open foo::bar, "test.pl" or die "$0 sadly cannot open test.pl: $!"; 22select foo::bar; 23$handle = \*foo::bar; 24$stash = \%foo::; 25*foo:: = *bar::; 26is select, $handle, 27 'select returns ref for glob whose stash has been detached'; 28 29open thwat::snin, "test.pl" or die "$0 is unable to open test.pl: $!"; 30select thwat::snin; 31$handle = \*thwat::snin; 32*thwat:: = *snin::; # gv is now *__ANON__::snin 33is select, $handle, 34 'select returns ref for glob with no stash pointer'; 35