|
7 | 7 | print STDIN "abc" ;
|
8 | 8 |
|
9 | 9 | Filehandle %s opened only for output [pp_print]
|
10 |
| - print <STDOUT> ; |
| 10 | + $a = <STDOUT> ; |
11 | 11 |
|
12 | 12 | print() on closed filehandle %s [pp_print]
|
13 | 13 | close STDIN ; print STDIN "abc" ;
|
@@ -62,27 +62,32 @@ print() on unopened filehandle abc at - line 4.
|
62 | 62 | ########
|
63 | 63 | # pp_hot.c [pp_print]
|
64 | 64 | use warnings 'io' ;
|
65 |
| -print STDIN "anc"; |
66 |
| -print <STDOUT>; |
67 |
| -print <STDERR>; |
68 |
| -open(FOO, ">&STDOUT") and print <FOO>; |
69 |
| -print getc(STDERR); |
70 |
| -print getc(FOO); |
71 |
| -#################################################################### |
72 |
| -# The next test is known to fail on some systems (Linux+old glibc, # |
73 |
| -# some *BSDs (including Mac OS X and NeXT), among others. # |
74 |
| -# We skip it for now (on the grounds that it is "just" a warning). # |
75 |
| -#################################################################### |
76 |
| -#read(FOO,$_,1); |
| 65 | +# There is no guarantee that STDOUT is output only, or STDIN input only. |
| 66 | +# Certainly on some BSDs (at least FreeBSD, Darwin, BSDi) file descriptors |
| 67 | +# 1 and 2 are opened read/write on the tty, and the IO layers may reflect this. |
| 68 | +# So we must make our own file handle that is read only. |
| 69 | +my $file = "./xcv" ; unlink $file ; |
| 70 | +open (FH, ">$file") or die $! ; |
| 71 | +close FH or die $! ; |
| 72 | +die "There is no file $file" unless -f $file ; |
| 73 | +open (FH, "<$file") or die $! ; |
| 74 | +print FH "anc" ; |
| 75 | +open(FOO, "<&FH") or die $! ; |
| 76 | +print FOO "anc" ; |
77 | 77 | no warnings 'io' ;
|
78 |
| -print STDIN "anc"; |
| 78 | +print FH "anc" ; |
| 79 | +print FOO "anc" ; |
| 80 | +use warnings 'io' ; |
| 81 | +print FH "anc" ; |
| 82 | +print FOO "anc" ; |
| 83 | +close (FH) or die $! ; |
| 84 | +close (FOO) or die $! ; |
| 85 | +unlink $file ; |
79 | 86 | EXPECT
|
80 |
| -Filehandle STDIN opened only for input at - line 3. |
81 |
| -Filehandle STDOUT opened only for output at - line 4. |
82 |
| -Filehandle STDERR opened only for output at - line 5. |
83 |
| -Filehandle FOO opened only for output at - line 6. |
84 |
| -Filehandle STDERR opened only for output at - line 7. |
85 |
| -Filehandle FOO opened only for output at - line 8. |
| 87 | +Filehandle FH opened only for input at - line 12. |
| 88 | +Filehandle FOO opened only for input at - line 14. |
| 89 | +Filehandle FH opened only for input at - line 19. |
| 90 | +Filehandle FOO opened only for input at - line 20. |
86 | 91 | ########
|
87 | 92 | # pp_hot.c [pp_print]
|
88 | 93 | use warnings 'closed' ;
|
@@ -150,14 +155,26 @@ readline() on closed filehandle STDIN at - line 4.
|
150 | 155 | # pp_hot.c [Perl_do_readline]
|
151 | 156 | use warnings 'io' ;
|
152 | 157 | my $file = "./xcv" ; unlink $file ;
|
153 |
| -open (FH, ">./xcv") ; |
| 158 | +open (FH, ">$file") or die $! ; |
154 | 159 | my $a = <FH> ;
|
155 | 160 | no warnings 'io' ;
|
156 | 161 | $a = <FH> ;
|
157 |
| -close (FH) ; |
| 162 | +use warnings 'io' ; |
| 163 | +open(FOO, ">&FH") or die $! ; |
| 164 | +$a = <FOO> ; |
| 165 | +no warnings 'io' ; |
| 166 | +$a = <FOO> ; |
| 167 | +use warnings 'io' ; |
| 168 | +$a = <FOO> ; |
| 169 | +$a = <FH> ; |
| 170 | +close (FH) or die $! ; |
| 171 | +close (FOO) or die $! ; |
158 | 172 | unlink $file ;
|
159 | 173 | EXPECT
|
160 | 174 | Filehandle FH opened only for output at - line 5.
|
| 175 | +Filehandle FOO opened only for output at - line 10. |
| 176 | +Filehandle FOO opened only for output at - line 14. |
| 177 | +Filehandle FH opened only for output at - line 15. |
161 | 178 | ########
|
162 | 179 | # pp_hot.c [Perl_sub_crush_depth]
|
163 | 180 | use warnings 'recursion' ;
|
|
0 commit comments