Commit | Line | Data |
---|---|---|
767a6a26 | 1 | pp_hot.c |
599cee73 | 2 | |
2dd78f96 | 3 | print() on unopened filehandle abc [pp_print] |
599cee73 PM |
4 | $f = $a = "abc" ; print $f $a |
5 | ||
767a6a26 | 6 | Filehandle %s opened only for input [pp_print] |
599cee73 PM |
7 | print STDIN "abc" ; |
8 | ||
767a6a26 | 9 | Filehandle %s opened only for output [pp_print] |
977289e4 | 10 | $a = <STDOUT> ; |
599cee73 | 11 | |
9a7dcd9c | 12 | print() on closed filehandle %s [pp_print] |
599cee73 PM |
13 | close STDIN ; print STDIN "abc" ; |
14 | ||
767a6a26 | 15 | uninitialized [pp_rv2av] |
599cee73 PM |
16 | my $a = undef ; my @b = @$a |
17 | ||
767a6a26 | 18 | uninitialized [pp_rv2hv] |
599cee73 PM |
19 | my $a = undef ; my %b = %$a |
20 | ||
767a6a26 | 21 | Odd number of elements in hash list [pp_aassign] |
599cee73 PM |
22 | %X = (1,2,3) ; |
23 | ||
767a6a26 | 24 | Reference found where even-sized list expected [pp_aassign] |
599cee73 PM |
25 | $X = [ 1 ..3 ]; |
26 | ||
767a6a26 PM |
27 | Filehandle %s opened only for output [Perl_do_readline] |
28 | open (FH, ">./xcv") ; | |
29 | my $a = <FH> ; | |
30 | ||
31 | glob failed (can't start child: %s) [Perl_do_readline] <<TODO | |
32 | ||
9a7dcd9c | 33 | readline() on closed filehandle %s [Perl_do_readline] |
599cee73 PM |
34 | close STDIN ; $a = <STDIN>; |
35 | ||
790090df HS |
36 | readline() on closed filehandle %s [Perl_do_readline] |
37 | readline(NONESUCH); | |
38 | ||
767a6a26 PM |
39 | glob failed (child exited with status %d%s) [Perl_do_readline] <<TODO |
40 | ||
41 | Deep recursion on subroutine \"%s\" [Perl_sub_crush_depth] | |
6bc102ca | 42 | sub fred { fred() if $a++ < 200} fred() |
599cee73 | 43 | |
767a6a26 | 44 | Deep recursion on anonymous subroutine [Perl_sub_crush_depth] |
6bc102ca | 45 | $a = sub { &$a if $a++ < 200} &$a |
599cee73 | 46 | |
d804643f SC |
47 | Use of reference "%s" as array index [pp_aelem] |
48 | $x[\1] | |
49 | ||
599cee73 | 50 | __END__ |
767a6a26 | 51 | # pp_hot.c [pp_print] |
4438c4b7 | 52 | use warnings 'unopened' ; |
599cee73 | 53 | $f = $a = "abc" ; |
0453d815 | 54 | print $f $a; |
4438c4b7 | 55 | no warnings 'unopened' ; |
0453d815 | 56 | print $f $a; |
cf26e47f NC |
57 | use warnings; |
58 | no warnings 'unopened' ; | |
59 | print $f $a; | |
599cee73 | 60 | EXPECT |
2dd78f96 | 61 | print() on unopened filehandle abc at - line 4. |
599cee73 | 62 | ######## |
767a6a26 | 63 | # pp_hot.c [pp_print] |
4438c4b7 | 64 | use warnings 'io' ; |
977289e4 NC |
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" ; | |
37bd1396 | 77 | no warnings 'io' ; |
977289e4 NC |
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 ; | |
599cee73 | 86 | EXPECT |
977289e4 NC |
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. | |
599cee73 | 91 | ######## |
767a6a26 | 92 | # pp_hot.c [pp_print] |
4438c4b7 | 93 | use warnings 'closed' ; |
599cee73 PM |
94 | close STDIN ; |
95 | print STDIN "anc"; | |
69282e91 GS |
96 | opendir STDIN, "."; |
97 | print STDIN "anc"; | |
98 | closedir STDIN; | |
4438c4b7 | 99 | no warnings 'closed' ; |
0453d815 | 100 | print STDIN "anc"; |
69282e91 GS |
101 | opendir STDIN, "."; |
102 | print STDIN "anc"; | |
cf26e47f NC |
103 | use warnings; |
104 | no warnings 'closed' ; | |
105 | print STDIN "anc"; | |
599cee73 | 106 | EXPECT |
43693395 GS |
107 | print() on closed filehandle STDIN at - line 4. |
108 | print() on closed filehandle STDIN at - line 6. | |
109 | (Are you trying to call print() on dirhandle STDIN?) | |
599cee73 | 110 | ######## |
f55e507d NC |
111 | # pp_hot.c [pp_print] |
112 | # [ID 20020425.012] from Dave Steiner <steiner@bakerst.rutgers.edu> | |
113 | # This goes segv on 5.7.3 | |
114 | use warnings 'closed' ; | |
115 | my $fh = *STDOUT{IO}; | |
116 | close STDOUT or die "Can't close STDOUT"; | |
117 | print $fh "Shouldn't print anything, but shouldn't SEGV either\n"; | |
118 | EXPECT | |
119 | print() on closed filehandle at - line 7. | |
120 | ######## | |
f62cb720 RGS |
121 | # pp_hot.c [pp_print] |
122 | package foo; | |
123 | use warnings 'closed'; | |
124 | open my $fh1, "nonexistent"; | |
125 | print $fh1 42; | |
126 | open $fh2, "nonexistent"; | |
127 | print $fh2 42; | |
128 | open $bar::fh3, "nonexistent"; | |
129 | print $bar::fh3 42; | |
130 | open bar::FH4, "nonexistent"; | |
131 | print bar::FH4 42; | |
132 | EXPECT | |
133 | print() on closed filehandle $fh1 at - line 5. | |
134 | print() on closed filehandle $fh2 at - line 7. | |
135 | print() on closed filehandle $fh3 at - line 9. | |
136 | print() on closed filehandle FH4 at - line 11. | |
137 | ######## | |
767a6a26 | 138 | # pp_hot.c [pp_rv2av] |
4438c4b7 | 139 | use warnings 'uninitialized' ; |
599cee73 | 140 | my $a = undef ; |
0453d815 | 141 | my @b = @$a; |
4438c4b7 | 142 | no warnings 'uninitialized' ; |
0453d815 | 143 | my @c = @$a; |
599cee73 | 144 | EXPECT |
29489e7c | 145 | Use of uninitialized value $a in array dereference at - line 4. |
599cee73 | 146 | ######## |
767a6a26 | 147 | # pp_hot.c [pp_rv2hv] |
4438c4b7 | 148 | use warnings 'uninitialized' ; |
599cee73 | 149 | my $a = undef ; |
0453d815 | 150 | my %b = %$a; |
4438c4b7 | 151 | no warnings 'uninitialized' ; |
0453d815 | 152 | my %c = %$a; |
599cee73 | 153 | EXPECT |
29489e7c | 154 | Use of uninitialized value $a in hash dereference at - line 4. |
599cee73 | 155 | ######## |
767a6a26 | 156 | # pp_hot.c [pp_aassign] |
e476b1b5 | 157 | use warnings 'misc' ; |
599cee73 | 158 | my %X ; %X = (1,2,3) ; |
e476b1b5 | 159 | no warnings 'misc' ; |
0453d815 | 160 | my %Y ; %Y = (1,2,3) ; |
599cee73 PM |
161 | EXPECT |
162 | Odd number of elements in hash assignment at - line 3. | |
163 | ######## | |
767a6a26 | 164 | # pp_hot.c [pp_aassign] |
e476b1b5 | 165 | use warnings 'misc' ; |
599cee73 | 166 | my %X ; %X = [1 .. 3] ; |
e476b1b5 | 167 | no warnings 'misc' ; |
0453d815 | 168 | my %Y ; %Y = [1 .. 3] ; |
599cee73 PM |
169 | EXPECT |
170 | Reference found where even-sized list expected at - line 3. | |
171 | ######## | |
767a6a26 | 172 | # pp_hot.c [Perl_do_readline] |
4438c4b7 | 173 | use warnings 'closed' ; |
69282e91 GS |
174 | close STDIN ; $a = <STDIN> ; |
175 | opendir STDIN, "." ; $a = <STDIN> ; | |
176 | closedir STDIN; | |
4438c4b7 | 177 | no warnings 'closed' ; |
69282e91 | 178 | opendir STDIN, "." ; $a = <STDIN> ; |
0453d815 | 179 | $a = <STDIN> ; |
599cee73 | 180 | EXPECT |
43693395 GS |
181 | readline() on closed filehandle STDIN at - line 3. |
182 | readline() on closed filehandle STDIN at - line 4. | |
183 | (Are you trying to call readline() on dirhandle STDIN?) | |
599cee73 | 184 | ######## |
767a6a26 PM |
185 | # pp_hot.c [Perl_do_readline] |
186 | use warnings 'io' ; | |
187 | my $file = "./xcv" ; unlink $file ; | |
977289e4 | 188 | open (FH, ">$file") or die $! ; |
767a6a26 PM |
189 | my $a = <FH> ; |
190 | no warnings 'io' ; | |
191 | $a = <FH> ; | |
977289e4 NC |
192 | use warnings 'io' ; |
193 | open(FOO, ">&FH") or die $! ; | |
194 | $a = <FOO> ; | |
195 | no warnings 'io' ; | |
196 | $a = <FOO> ; | |
197 | use warnings 'io' ; | |
198 | $a = <FOO> ; | |
199 | $a = <FH> ; | |
200 | close (FH) or die $! ; | |
201 | close (FOO) or die $! ; | |
767a6a26 PM |
202 | unlink $file ; |
203 | EXPECT | |
43693395 | 204 | Filehandle FH opened only for output at - line 5. |
977289e4 NC |
205 | Filehandle FOO opened only for output at - line 10. |
206 | Filehandle FOO opened only for output at - line 14. | |
207 | Filehandle FH opened only for output at - line 15. | |
767a6a26 PM |
208 | ######## |
209 | # pp_hot.c [Perl_sub_crush_depth] | |
4438c4b7 | 210 | use warnings 'recursion' ; |
599cee73 PM |
211 | sub fred |
212 | { | |
213 | fred() if $a++ < 200 | |
214 | } | |
4a925ff6 GS |
215 | { |
216 | local $SIG{__WARN__} = sub { | |
217 | die "ok\n" if $_[0] =~ /^Deep recursion on subroutine "main::fred"/ | |
218 | }; | |
219 | fred(); | |
220 | } | |
599cee73 | 221 | EXPECT |
4a925ff6 | 222 | ok |
599cee73 | 223 | ######## |
767a6a26 | 224 | # pp_hot.c [Perl_sub_crush_depth] |
4438c4b7 | 225 | no warnings 'recursion' ; |
0453d815 PM |
226 | sub fred |
227 | { | |
228 | fred() if $a++ < 200 | |
229 | } | |
230 | { | |
231 | local $SIG{__WARN__} = sub { | |
232 | die "ok\n" if $_[0] =~ /^Deep recursion on subroutine "main::fred"/ | |
233 | }; | |
234 | fred(); | |
235 | } | |
236 | EXPECT | |
237 | ||
238 | ######## | |
767a6a26 | 239 | # pp_hot.c [Perl_sub_crush_depth] |
4438c4b7 | 240 | use warnings 'recursion' ; |
599cee73 PM |
241 | $b = sub |
242 | { | |
243 | &$b if $a++ < 200 | |
244 | } ; | |
245 | ||
246 | &$b ; | |
247 | EXPECT | |
248 | Deep recursion on anonymous subroutine at - line 5. | |
0453d815 | 249 | ######## |
767a6a26 | 250 | # pp_hot.c [Perl_sub_crush_depth] |
4438c4b7 | 251 | no warnings 'recursion' ; |
0453d815 PM |
252 | $b = sub |
253 | { | |
254 | &$b if $a++ < 200 | |
255 | } ; | |
256 | ||
257 | &$b ; | |
258 | EXPECT | |
6bc102ca GS |
259 | ######## |
260 | # pp_hot.c [pp_concat] | |
8d6d96c1 HS |
261 | use warnings 'uninitialized'; |
262 | my($x, $y); | |
263 | sub a { shift } | |
264 | a($x . "x"); # should warn once | |
265 | a($x . $y); # should warn twice | |
266 | $x .= $y; # should warn once | |
267 | $y .= $y; # should warn once | |
268 | EXPECT | |
29489e7c | 269 | Use of uninitialized value $x in concatenation (.) or string at - line 5. |
29489e7c | 270 | Use of uninitialized value $x in concatenation (.) or string at - line 6. |
c75ab21a | 271 | Use of uninitialized value $y in concatenation (.) or string at - line 6. |
29489e7c DM |
272 | Use of uninitialized value $y in concatenation (.) or string at - line 7. |
273 | Use of uninitialized value $y in concatenation (.) or string at - line 8. | |
8d6d96c1 | 274 | ######## |
d804643f SC |
275 | # pp_hot.c [pp_aelem] |
276 | { | |
277 | use warnings 'misc'; | |
278 | print $x[\1]; | |
279 | } | |
280 | { | |
281 | no warnings 'misc'; | |
282 | print $x[\1]; | |
283 | } | |
284 | ||
285 | EXPECT | |
286 | OPTION regex | |
287 | Use of reference ".*" as array index at - line 4. | |
1f1cc344 JH |
288 | ######## |
289 | # pp_hot.c [pp_aelem] | |
290 | package Foo;use overload q("") => sub {};package main;$a = bless {}, "Foo"; | |
291 | $b = {}; | |
292 | { | |
293 | use warnings 'misc'; | |
294 | print $x[$a]; | |
295 | print $x[$b]; | |
296 | } | |
297 | { | |
298 | no warnings 'misc'; | |
299 | print $x[$a]; | |
300 | print $x[$b]; | |
301 | } | |
302 | ||
303 | EXPECT | |
304 | OPTION regex | |
305 | Use of reference ".*" as array index at - line 7. |