Commit | Line | Data |
767a6a26 |
1 | pp_hot.c |
599cee73 |
2 | |
2dd78f96 |
3 | print() on unopened filehandle abc [pp_print] |
599cee73 |
4 | $f = $a = "abc" ; print $f $a |
5 | |
767a6a26 |
6 | Filehandle %s opened only for input [pp_print] |
599cee73 |
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 |
13 | close STDIN ; print STDIN "abc" ; |
14 | |
767a6a26 |
15 | uninitialized [pp_rv2av] |
599cee73 |
16 | my $a = undef ; my @b = @$a |
17 | |
767a6a26 |
18 | uninitialized [pp_rv2hv] |
599cee73 |
19 | my $a = undef ; my %b = %$a |
20 | |
767a6a26 |
21 | Odd number of elements in hash list [pp_aassign] |
599cee73 |
22 | %X = (1,2,3) ; |
23 | |
767a6a26 |
24 | Reference found where even-sized list expected [pp_aassign] |
599cee73 |
25 | $X = [ 1 ..3 ]; |
26 | |
767a6a26 |
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 |
34 | close STDIN ; $a = <STDIN>; |
35 | |
790090df |
36 | readline() on closed filehandle %s [Perl_do_readline] |
37 | readline(NONESUCH); |
38 | |
767a6a26 |
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 | |
6bc102ca |
47 | Possible Y2K bug: about to append an integer to '19' [pp_concat] |
48 | $x = "19$yy\n"; |
767a6a26 |
49 | |
d804643f |
50 | Use of reference "%s" as array index [pp_aelem] |
51 | $x[\1] |
52 | |
599cee73 |
53 | __END__ |
767a6a26 |
54 | # pp_hot.c [pp_print] |
4438c4b7 |
55 | use warnings 'unopened' ; |
599cee73 |
56 | $f = $a = "abc" ; |
0453d815 |
57 | print $f $a; |
4438c4b7 |
58 | no warnings 'unopened' ; |
0453d815 |
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 |
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 |
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 |
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 |
94 | close STDIN ; |
95 | print STDIN "anc"; |
69282e91 |
96 | opendir STDIN, "."; |
97 | print STDIN "anc"; |
98 | closedir STDIN; |
4438c4b7 |
99 | no warnings 'closed' ; |
0453d815 |
100 | print STDIN "anc"; |
69282e91 |
101 | opendir STDIN, "."; |
102 | print STDIN "anc"; |
599cee73 |
103 | EXPECT |
43693395 |
104 | print() on closed filehandle STDIN at - line 4. |
105 | print() on closed filehandle STDIN at - line 6. |
106 | (Are you trying to call print() on dirhandle STDIN?) |
599cee73 |
107 | ######## |
767a6a26 |
108 | # pp_hot.c [pp_rv2av] |
4438c4b7 |
109 | use warnings 'uninitialized' ; |
599cee73 |
110 | my $a = undef ; |
0453d815 |
111 | my @b = @$a; |
4438c4b7 |
112 | no warnings 'uninitialized' ; |
0453d815 |
113 | my @c = @$a; |
599cee73 |
114 | EXPECT |
b89fed5f |
115 | Use of uninitialized value in array dereference at - line 4. |
599cee73 |
116 | ######## |
767a6a26 |
117 | # pp_hot.c [pp_rv2hv] |
4438c4b7 |
118 | use warnings 'uninitialized' ; |
599cee73 |
119 | my $a = undef ; |
0453d815 |
120 | my %b = %$a; |
4438c4b7 |
121 | no warnings 'uninitialized' ; |
0453d815 |
122 | my %c = %$a; |
599cee73 |
123 | EXPECT |
b89fed5f |
124 | Use of uninitialized value in hash dereference at - line 4. |
599cee73 |
125 | ######## |
767a6a26 |
126 | # pp_hot.c [pp_aassign] |
e476b1b5 |
127 | use warnings 'misc' ; |
599cee73 |
128 | my %X ; %X = (1,2,3) ; |
e476b1b5 |
129 | no warnings 'misc' ; |
0453d815 |
130 | my %Y ; %Y = (1,2,3) ; |
599cee73 |
131 | EXPECT |
132 | Odd number of elements in hash assignment at - line 3. |
133 | ######## |
767a6a26 |
134 | # pp_hot.c [pp_aassign] |
e476b1b5 |
135 | use warnings 'misc' ; |
599cee73 |
136 | my %X ; %X = [1 .. 3] ; |
e476b1b5 |
137 | no warnings 'misc' ; |
0453d815 |
138 | my %Y ; %Y = [1 .. 3] ; |
599cee73 |
139 | EXPECT |
140 | Reference found where even-sized list expected at - line 3. |
141 | ######## |
767a6a26 |
142 | # pp_hot.c [Perl_do_readline] |
4438c4b7 |
143 | use warnings 'closed' ; |
69282e91 |
144 | close STDIN ; $a = <STDIN> ; |
145 | opendir STDIN, "." ; $a = <STDIN> ; |
146 | closedir STDIN; |
4438c4b7 |
147 | no warnings 'closed' ; |
69282e91 |
148 | opendir STDIN, "." ; $a = <STDIN> ; |
0453d815 |
149 | $a = <STDIN> ; |
599cee73 |
150 | EXPECT |
43693395 |
151 | readline() on closed filehandle STDIN at - line 3. |
152 | readline() on closed filehandle STDIN at - line 4. |
153 | (Are you trying to call readline() on dirhandle STDIN?) |
599cee73 |
154 | ######## |
767a6a26 |
155 | # pp_hot.c [Perl_do_readline] |
156 | use warnings 'io' ; |
157 | my $file = "./xcv" ; unlink $file ; |
977289e4 |
158 | open (FH, ">$file") or die $! ; |
767a6a26 |
159 | my $a = <FH> ; |
160 | no warnings 'io' ; |
161 | $a = <FH> ; |
977289e4 |
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 $! ; |
767a6a26 |
172 | unlink $file ; |
173 | EXPECT |
43693395 |
174 | Filehandle FH opened only for output at - line 5. |
977289e4 |
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. |
767a6a26 |
178 | ######## |
179 | # pp_hot.c [Perl_sub_crush_depth] |
4438c4b7 |
180 | use warnings 'recursion' ; |
599cee73 |
181 | sub fred |
182 | { |
183 | fred() if $a++ < 200 |
184 | } |
4a925ff6 |
185 | { |
186 | local $SIG{__WARN__} = sub { |
187 | die "ok\n" if $_[0] =~ /^Deep recursion on subroutine "main::fred"/ |
188 | }; |
189 | fred(); |
190 | } |
599cee73 |
191 | EXPECT |
4a925ff6 |
192 | ok |
599cee73 |
193 | ######## |
767a6a26 |
194 | # pp_hot.c [Perl_sub_crush_depth] |
4438c4b7 |
195 | no warnings 'recursion' ; |
0453d815 |
196 | sub fred |
197 | { |
198 | fred() if $a++ < 200 |
199 | } |
200 | { |
201 | local $SIG{__WARN__} = sub { |
202 | die "ok\n" if $_[0] =~ /^Deep recursion on subroutine "main::fred"/ |
203 | }; |
204 | fred(); |
205 | } |
206 | EXPECT |
207 | |
208 | ######## |
767a6a26 |
209 | # pp_hot.c [Perl_sub_crush_depth] |
4438c4b7 |
210 | use warnings 'recursion' ; |
599cee73 |
211 | $b = sub |
212 | { |
213 | &$b if $a++ < 200 |
214 | } ; |
215 | |
216 | &$b ; |
217 | EXPECT |
218 | Deep recursion on anonymous subroutine at - line 5. |
0453d815 |
219 | ######## |
767a6a26 |
220 | # pp_hot.c [Perl_sub_crush_depth] |
4438c4b7 |
221 | no warnings 'recursion' ; |
0453d815 |
222 | $b = sub |
223 | { |
224 | &$b if $a++ < 200 |
225 | } ; |
226 | |
227 | &$b ; |
228 | EXPECT |
6bc102ca |
229 | ######## |
230 | # pp_hot.c [pp_concat] |
8d6d96c1 |
231 | use warnings 'uninitialized'; |
232 | my($x, $y); |
233 | sub a { shift } |
234 | a($x . "x"); # should warn once |
235 | a($x . $y); # should warn twice |
236 | $x .= $y; # should warn once |
237 | $y .= $y; # should warn once |
238 | EXPECT |
239 | Use of uninitialized value in concatenation (.) or string at - line 5. |
240 | Use of uninitialized value in concatenation (.) or string at - line 6. |
241 | Use of uninitialized value in concatenation (.) or string at - line 6. |
242 | Use of uninitialized value in concatenation (.) or string at - line 7. |
243 | Use of uninitialized value in concatenation (.) or string at - line 8. |
244 | ######## |
245 | # pp_hot.c [pp_concat] |
e476b1b5 |
246 | use warnings 'y2k'; |
6bc102ca |
247 | use Config; |
248 | BEGIN { |
249 | unless ($Config{ccflags} =~ /Y2KWARN/) { |
250 | print "SKIPPED\n# perl not built with -DPERL_Y2KWARN"; |
251 | exit 0; |
252 | } |
253 | } |
254 | my $x; |
255 | my $yy = 78; |
256 | $x = "19$yy\n"; |
257 | $x = "19" . $yy . "\n"; |
258 | $x = "319$yy\n"; |
259 | $x = "319" . $yy . "\n"; |
777b0c87 |
260 | $yy = 19; |
261 | $x = "ok $yy\n"; |
262 | $yy = 9; |
263 | $x = 1 . $yy; |
e476b1b5 |
264 | no warnings 'y2k'; |
6bc102ca |
265 | $x = "19$yy\n"; |
266 | $x = "19" . $yy . "\n"; |
267 | EXPECT |
268 | Possible Y2K bug: about to append an integer to '19' at - line 12. |
269 | Possible Y2K bug: about to append an integer to '19' at - line 13. |
d804643f |
270 | ######## |
271 | # pp_hot.c [pp_aelem] |
272 | { |
273 | use warnings 'misc'; |
274 | print $x[\1]; |
275 | } |
276 | { |
277 | no warnings 'misc'; |
278 | print $x[\1]; |
279 | } |
280 | |
281 | EXPECT |
282 | OPTION regex |
283 | Use of reference ".*" as array index at - line 4. |
1f1cc344 |
284 | ######## |
285 | # pp_hot.c [pp_aelem] |
286 | package Foo;use overload q("") => sub {};package main;$a = bless {}, "Foo"; |
287 | $b = {}; |
288 | { |
289 | use warnings 'misc'; |
290 | print $x[$a]; |
291 | print $x[$b]; |
292 | } |
293 | { |
294 | no warnings 'misc'; |
295 | print $x[$a]; |
296 | print $x[$b]; |
297 | } |
298 | |
299 | EXPECT |
300 | OPTION regex |
301 | Use of reference ".*" as array index at - line 7. |