warning for split(/.../g, ...);
[p5sagit/p5-mst-13.2.git] / t / lib / warnings / op
1   op.c          AOK
2
3      "my" variable %s masks earlier declaration in same scope
4         my $x;
5         my $x ;
6
7      Variable "%s" may be unavailable 
8         sub x {
9             my $x;
10             sub y {
11                 $x
12             }
13         }
14
15      Variable "%s" will not stay shared 
16         sub x {
17             my $x;
18             sub y {
19                 sub { $x }
20             }
21         }
22
23      Found = in conditional, should be ==
24         1 if $a = 1 ;
25
26      Use of implicit split to @_ is deprecated
27         split ;
28
29      Use of implicit split to @_ is deprecated
30         $a = split ;
31
32      Useless use of time in void context
33      Useless use of a variable in void context
34      Useless use of a constant in void context
35         time ;
36         $a ;
37         "abc"
38
39      Useless use of sort in scalar context
40         my $x = sort (2,1,3);
41
42      Applying %s to %s will act on scalar(%s)
43         my $a ; my @a = () ; my %a = () ; my $b = \@a ; my $c = \%a ;
44         @a =~ /abc/ ;
45         @a =~ s/a/b/ ;
46         @a =~ tr/a/b/ ;
47         @$b =~ /abc/ ;
48         @$b =~ s/a/b/ ;
49         @$b =~ tr/a/b/ ;
50         %a =~ /abc/ ;
51         %a =~ s/a/b/ ;
52         %a =~ tr/a/b/ ;
53         %$c =~ /abc/ ;
54         %$c =~ s/a/b/ ;
55         %$c =~ tr/a/b/ ;
56
57
58      Parentheses missing around "my" list at -e line 1.
59        my $a, $b = (1,2);
60  
61      Parentheses missing around "local" list at -e line 1.
62        local $a, $b = (1,2);
63  
64      Bareword found in conditional at -e line 1.
65        use warnings 'bareword'; my $x = print(ABC || 1);
66  
67      Value of %s may be \"0\"; use \"defined\" 
68         $x = 1 if $x = <FH> ;
69         $x = 1 while $x = <FH> ;
70
71      Subroutine fred redefined at -e line 1.
72        sub fred{1;} sub fred{1;}
73  
74      Constant subroutine %s redefined 
75         sub fred() {1;} sub fred() {1;}
76  
77      Format FRED redefined at /tmp/x line 5.
78        format FRED =
79        .
80        format FRED =
81        .
82  
83      Array @%s missing the @ in argument %d of %s() 
84         push fred ;
85  
86      Hash %%%s missing the %% in argument %d of %s() 
87         keys joe ;
88  
89      Statement unlikely to be reached
90         (Maybe you meant system() when you said exec()?
91         exec "true" ; my $a
92
93      defined(@array) is deprecated
94         (Maybe you should just omit the defined()?)
95         my @a ; defined @a ;
96         defined (@a = (1,2,3)) ;
97
98      defined(%hash) is deprecated
99         (Maybe you should just omit the defined()?)
100         my %h ; defined %h ;
101     
102      /---/ should probably be written as "---"
103         join(/---/, @foo);
104
105     %s() called too early to check prototype            [Perl_peep]
106         fred() ; sub fred ($$) {}
107
108
109      Use of "package" with no arguments is deprecated
110         package;
111
112     Package `%s' not found (did you use the incorrect case?)
113
114     Use of /g modifier is meaningless in split
115
116     Mandatory Warnings 
117     ------------------
118     Prototype mismatch:         [cv_ckproto]
119         sub fred() ;
120         sub fred($) {}
121
122     %s never introduced         [pad_leavemy]   TODO
123     Runaway prototype           [newSUB]        TODO
124     oops: oopsAV                [oopsAV]        TODO
125     oops: oopsHV                [oopsHV]        TODO
126     
127
128 __END__
129 # op.c
130 use warnings 'misc' ;
131 my $x ;
132 my $x ;
133 no warnings 'misc' ;
134 my $x ;
135 EXPECT
136 "my" variable $x masks earlier declaration in same scope at - line 4.
137 ########
138 # op.c
139 use warnings 'closure' ;
140 sub x {
141       my $x;
142       sub y {
143          $x
144       }
145    }
146 EXPECT
147 Variable "$x" will not stay shared at - line 7.
148 ########
149 # op.c
150 no warnings 'closure' ;
151 sub x {
152       my $x;
153       sub y {
154          $x
155       }
156    }
157 EXPECT
158
159 ########
160 # op.c
161 use warnings 'closure' ;
162 sub x {
163       our $x;
164       sub y {
165          $x
166       }
167    }
168 EXPECT
169
170 ########
171 # op.c
172 use warnings 'closure' ;
173 sub x {
174       my $x;
175       sub y {
176          sub { $x }
177       }
178    }
179 EXPECT
180 Variable "$x" may be unavailable at - line 6.
181 ########
182 # op.c
183 no warnings 'closure' ;
184 sub x {
185       my $x;
186       sub y {
187          sub { $x }
188       }
189    }
190 EXPECT
191
192 ########
193 # op.c
194 use warnings 'syntax' ;
195 1 if $a = 1 ;
196 no warnings 'syntax' ;
197 1 if $a = 1 ;
198 EXPECT
199 Found = in conditional, should be == at - line 3.
200 ########
201 # op.c
202 use warnings 'deprecated' ;
203 split ;
204 no warnings 'deprecated' ;
205 split ;
206 EXPECT
207 Use of implicit split to @_ is deprecated at - line 3.
208 ########
209 # op.c
210 use warnings 'deprecated' ;
211 $a = split ;
212 no warnings 'deprecated' ;
213 $a = split ;
214 EXPECT
215 Use of implicit split to @_ is deprecated at - line 3.
216 ########
217 # op.c
218 use warnings 'deprecated';
219 my (@foo, %foo);
220 %main::foo->{"bar"};
221 %foo->{"bar"};
222 @main::foo->[23];
223 @foo->[23];
224 $main::foo = {}; %$main::foo->{"bar"};
225 $foo = {}; %$foo->{"bar"};
226 $main::foo = []; @$main::foo->[34];
227 $foo = []; @$foo->[34];
228 no warnings 'deprecated';
229 %main::foo->{"bar"};
230 %foo->{"bar"};
231 @main::foo->[23];
232 @foo->[23];
233 $main::foo = {}; %$main::foo->{"bar"};
234 $foo = {}; %$foo->{"bar"};
235 $main::foo = []; @$main::foo->[34];
236 $foo = []; @$foo->[34];
237 EXPECT
238 Using a hash as a reference is deprecated at - line 4.
239 Using a hash as a reference is deprecated at - line 5.
240 Using an array as a reference is deprecated at - line 6.
241 Using an array as a reference is deprecated at - line 7.
242 Using a hash as a reference is deprecated at - line 8.
243 Using a hash as a reference is deprecated at - line 9.
244 Using an array as a reference is deprecated at - line 10.
245 Using an array as a reference is deprecated at - line 11.
246 ########
247 # op.c
248 use warnings 'void' ; close STDIN ;
249 1 x 3 ;                 # OP_REPEAT
250                         # OP_GVSV
251 wantarray ;             # OP_WANTARRAY
252                         # OP_GV
253                         # OP_PADSV
254                         # OP_PADAV
255                         # OP_PADHV
256                         # OP_PADANY
257                         # OP_AV2ARYLEN
258 ref ;                   # OP_REF
259 \@a ;                   # OP_REFGEN
260 \$a ;                   # OP_SREFGEN
261 defined $a ;            # OP_DEFINED
262 hex $a ;                # OP_HEX
263 oct $a ;                # OP_OCT
264 length $a ;             # OP_LENGTH
265 substr $a,1 ;           # OP_SUBSTR
266 vec $a,1,2 ;            # OP_VEC
267 index $a,1,2 ;          # OP_INDEX
268 rindex $a,1,2 ;         # OP_RINDEX
269 sprintf $a ;            # OP_SPRINTF
270 $a[0] ;                 # OP_AELEM
271                         # OP_AELEMFAST
272 @a[0] ;                 # OP_ASLICE
273 #values %a ;            # OP_VALUES
274 #keys %a ;              # OP_KEYS
275 $a{0} ;                 # OP_HELEM
276 @a{0} ;                 # OP_HSLICE
277 unpack "a", "a" ;       # OP_UNPACK
278 pack $a,"" ;            # OP_PACK
279 join "" ;               # OP_JOIN
280 (@a)[0,1] ;             # OP_LSLICE
281                         # OP_ANONLIST
282                         # OP_ANONHASH
283 sort(1,2) ;             # OP_SORT
284 reverse(1,2) ;          # OP_REVERSE
285                         # OP_RANGE
286                         # OP_FLIP
287 (1 ..2) ;               # OP_FLOP
288 caller ;                # OP_CALLER
289 fileno STDIN ;          # OP_FILENO
290 eof STDIN ;             # OP_EOF
291 tell STDIN ;            # OP_TELL
292 readlink 1;             # OP_READLINK
293 time ;                  # OP_TIME
294 localtime ;             # OP_LOCALTIME
295 gmtime ;                # OP_GMTIME
296 eval { getgrnam 1 };    # OP_GGRNAM
297 eval { getgrgid 1 };    # OP_GGRGID
298 eval { getpwnam 1 };    # OP_GPWNAM
299 eval { getpwuid 1 };    # OP_GPWUID
300 EXPECT
301 Useless use of repeat (x) in void context at - line 3.
302 Useless use of wantarray in void context at - line 5.
303 Useless use of reference-type operator in void context at - line 12.
304 Useless use of reference constructor in void context at - line 13.
305 Useless use of single ref constructor in void context at - line 14.
306 Useless use of defined operator in void context at - line 15.
307 Useless use of hex in void context at - line 16.
308 Useless use of oct in void context at - line 17.
309 Useless use of length in void context at - line 18.
310 Useless use of substr in void context at - line 19.
311 Useless use of vec in void context at - line 20.
312 Useless use of index in void context at - line 21.
313 Useless use of rindex in void context at - line 22.
314 Useless use of sprintf in void context at - line 23.
315 Useless use of array element in void context at - line 24.
316 Useless use of array slice in void context at - line 26.
317 Useless use of hash element in void context at - line 29.
318 Useless use of hash slice in void context at - line 30.
319 Useless use of unpack in void context at - line 31.
320 Useless use of pack in void context at - line 32.
321 Useless use of join or string in void context at - line 33.
322 Useless use of list slice in void context at - line 34.
323 Useless use of sort in void context at - line 37.
324 Useless use of reverse in void context at - line 38.
325 Useless use of range (or flop) in void context at - line 41.
326 Useless use of caller in void context at - line 42.
327 Useless use of fileno in void context at - line 43.
328 Useless use of eof in void context at - line 44.
329 Useless use of tell in void context at - line 45.
330 Useless use of readlink in void context at - line 46.
331 Useless use of time in void context at - line 47.
332 Useless use of localtime in void context at - line 48.
333 Useless use of gmtime in void context at - line 49.
334 Useless use of getgrnam in void context at - line 50.
335 Useless use of getgrgid in void context at - line 51.
336 Useless use of getpwnam in void context at - line 52.
337 Useless use of getpwuid in void context at - line 53.
338 ########
339 # op.c
340 use warnings 'void' ; close STDIN ;
341 my $x = sort (2,1,3);
342 no warnings 'void' ;
343 $x = sort (2,1,3);
344 EXPECT
345 Useless use of sort in scalar context at - line 3.
346 ########
347 # op.c
348 no warnings 'void' ; close STDIN ;
349 1 x 3 ;                 # OP_REPEAT
350                         # OP_GVSV
351 wantarray ;             # OP_WANTARRAY
352                         # OP_GV
353                         # OP_PADSV
354                         # OP_PADAV
355                         # OP_PADHV
356                         # OP_PADANY
357                         # OP_AV2ARYLEN
358 ref ;                   # OP_REF
359 \@a ;                   # OP_REFGEN
360 \$a ;                   # OP_SREFGEN
361 defined $a ;            # OP_DEFINED
362 hex $a ;                # OP_HEX
363 oct $a ;                # OP_OCT
364 length $a ;             # OP_LENGTH
365 substr $a,1 ;           # OP_SUBSTR
366 vec $a,1,2 ;            # OP_VEC
367 index $a,1,2 ;          # OP_INDEX
368 rindex $a,1,2 ;         # OP_RINDEX
369 sprintf $a ;            # OP_SPRINTF
370 $a[0] ;                 # OP_AELEM
371                         # OP_AELEMFAST
372 @a[0] ;                 # OP_ASLICE
373 #values %a ;            # OP_VALUES
374 #keys %a ;              # OP_KEYS
375 $a{0} ;                 # OP_HELEM
376 @a{0} ;                 # OP_HSLICE
377 unpack "a", "a" ;       # OP_UNPACK
378 pack $a,"" ;            # OP_PACK
379 join "" ;               # OP_JOIN
380 (@a)[0,1] ;             # OP_LSLICE
381                         # OP_ANONLIST
382                         # OP_ANONHASH
383 sort(1,2) ;             # OP_SORT
384 reverse(1,2) ;          # OP_REVERSE
385                         # OP_RANGE
386                         # OP_FLIP
387 (1 ..2) ;               # OP_FLOP
388 caller ;                # OP_CALLER
389 fileno STDIN ;          # OP_FILENO
390 eof STDIN ;             # OP_EOF
391 tell STDIN ;            # OP_TELL
392 readlink 1;             # OP_READLINK
393 time ;                  # OP_TIME
394 localtime ;             # OP_LOCALTIME
395 gmtime ;                # OP_GMTIME
396 eval { getgrnam 1 };    # OP_GGRNAM
397 eval { getgrgid 1 };    # OP_GGRGID
398 eval { getpwnam 1 };    # OP_GPWNAM
399 eval { getpwuid 1 };    # OP_GPWUID
400 EXPECT
401 ########
402 # op.c
403 use warnings 'void' ;
404 for (@{[0]}) { "$_" }           # check warning isn't duplicated
405 no warnings 'void' ;
406 for (@{[0]}) { "$_" }           # check warning isn't duplicated
407 EXPECT
408 Useless use of string in void context at - line 3.
409 ########
410 # op.c
411 use warnings 'void' ;
412 use Config ;
413 BEGIN {
414     if ( ! $Config{d_telldir}) {
415         print <<EOM ;
416 SKIPPED
417 # telldir not present
418 EOM
419         exit 
420     }
421 }
422 telldir 1 ;             # OP_TELLDIR
423 no warnings 'void' ;
424 telldir 1 ;             # OP_TELLDIR
425 EXPECT
426 Useless use of telldir in void context at - line 13.
427 ########
428 # op.c
429 use warnings 'void' ;
430 use Config ;
431 BEGIN {
432     if ( ! $Config{d_getppid}) {
433         print <<EOM ;
434 SKIPPED
435 # getppid not present
436 EOM
437         exit 
438     }
439 }
440 getppid ;               # OP_GETPPID
441 no warnings 'void' ;
442 getppid ;               # OP_GETPPID
443 EXPECT
444 Useless use of getppid in void context at - line 13.
445 ########
446 # op.c
447 use warnings 'void' ;
448 use Config ;
449 BEGIN {
450     if ( ! $Config{d_getpgrp}) {
451         print <<EOM ;
452 SKIPPED
453 # getpgrp not present
454 EOM
455         exit 
456     }
457 }
458 getpgrp ;               # OP_GETPGRP
459 no warnings 'void' ;
460 getpgrp ;               # OP_GETPGRP
461 EXPECT
462 Useless use of getpgrp in void context at - line 13.
463 ########
464 # op.c
465 use warnings 'void' ;
466 use Config ;
467 BEGIN {
468     if ( ! $Config{d_times}) {
469         print <<EOM ;
470 SKIPPED
471 # times not present
472 EOM
473         exit 
474     }
475 }
476 times ;                 # OP_TMS
477 no warnings 'void' ;
478 times ;                 # OP_TMS
479 EXPECT
480 Useless use of times in void context at - line 13.
481 ########
482 # op.c
483 use warnings 'void' ;
484 use Config ;
485 BEGIN {
486     if ( ! $Config{d_getprior} or $^O eq 'os2') { # Locks before fixpak22
487         print <<EOM ;
488 SKIPPED
489 # getpriority not present
490 EOM
491         exit 
492     }
493 }
494 getpriority 1,2;        # OP_GETPRIORITY
495 no warnings 'void' ;
496 getpriority 1,2;        # OP_GETPRIORITY
497 EXPECT
498 Useless use of getpriority in void context at - line 13.
499 ########
500 # op.c
501 use warnings 'void' ;
502 use Config ;
503 BEGIN {
504     if ( ! $Config{d_getlogin}) {
505         print <<EOM ;
506 SKIPPED
507 # getlogin not present
508 EOM
509         exit 
510     }
511 }
512 getlogin ;                      # OP_GETLOGIN
513 no warnings 'void' ;
514 getlogin ;                      # OP_GETLOGIN
515 EXPECT
516 Useless use of getlogin in void context at - line 13.
517 ########
518 # op.c
519 use warnings 'void' ;
520 use Config ; BEGIN {
521 if ( ! $Config{d_socket}) {
522     print <<EOM ;
523 SKIPPED
524 # getsockname not present
525 # getpeername not present
526 # gethostbyname not present
527 # gethostbyaddr not present
528 # gethostent not present
529 # getnetbyname not present
530 # getnetbyaddr not present
531 # getnetent not present
532 # getprotobyname not present
533 # getprotobynumber not present
534 # getprotoent not present
535 # getservbyname not present
536 # getservbyport not present
537 # getservent not present
538 EOM
539     exit 
540 } }
541 getsockname STDIN ;     # OP_GETSOCKNAME
542 getpeername STDIN ;     # OP_GETPEERNAME
543 gethostbyname 1 ;       # OP_GHBYNAME
544 gethostbyaddr 1,2;      # OP_GHBYADDR
545 gethostent ;            # OP_GHOSTENT
546 getnetbyname 1 ;        # OP_GNBYNAME
547 getnetbyaddr 1,2 ;      # OP_GNBYADDR
548 getnetent ;             # OP_GNETENT
549 getprotobyname 1;       # OP_GPBYNAME
550 getprotobynumber 1;     # OP_GPBYNUMBER
551 getprotoent ;           # OP_GPROTOENT
552 getservbyname 1,2;      # OP_GSBYNAME
553 getservbyport 1,2;      # OP_GSBYPORT
554 getservent ;            # OP_GSERVENT
555
556 no warnings 'void' ;
557 getsockname STDIN ;     # OP_GETSOCKNAME
558 getpeername STDIN ;     # OP_GETPEERNAME
559 gethostbyname 1 ;       # OP_GHBYNAME
560 gethostbyaddr 1,2;      # OP_GHBYADDR
561 gethostent ;            # OP_GHOSTENT
562 getnetbyname 1 ;        # OP_GNBYNAME
563 getnetbyaddr 1,2 ;      # OP_GNBYADDR
564 getnetent ;             # OP_GNETENT
565 getprotobyname 1;       # OP_GPBYNAME
566 getprotobynumber 1;     # OP_GPBYNUMBER
567 getprotoent ;           # OP_GPROTOENT
568 getservbyname 1,2;      # OP_GSBYNAME
569 getservbyport 1,2;      # OP_GSBYPORT
570 getservent ;            # OP_GSERVENT
571 INIT {
572    # some functions may not be there, so we exit without running
573    exit;
574 }
575 EXPECT
576 Useless use of getsockname in void context at - line 24.
577 Useless use of getpeername in void context at - line 25.
578 Useless use of gethostbyname in void context at - line 26.
579 Useless use of gethostbyaddr in void context at - line 27.
580 Useless use of gethostent in void context at - line 28.
581 Useless use of getnetbyname in void context at - line 29.
582 Useless use of getnetbyaddr in void context at - line 30.
583 Useless use of getnetent in void context at - line 31.
584 Useless use of getprotobyname in void context at - line 32.
585 Useless use of getprotobynumber in void context at - line 33.
586 Useless use of getprotoent in void context at - line 34.
587 Useless use of getservbyname in void context at - line 35.
588 Useless use of getservbyport in void context at - line 36.
589 Useless use of getservent in void context at - line 37.
590 ########
591 # op.c
592 use warnings 'void' ;
593 *a ; # OP_RV2GV
594 $a ; # OP_RV2SV
595 @a ; # OP_RV2AV
596 %a ; # OP_RV2HV
597 no warnings 'void' ;
598 *a ; # OP_RV2GV
599 $a ; # OP_RV2SV
600 @a ; # OP_RV2AV
601 %a ; # OP_RV2HV
602 EXPECT
603 Useless use of a variable in void context at - line 3.
604 Useless use of a variable in void context at - line 4.
605 Useless use of a variable in void context at - line 5.
606 Useless use of a variable in void context at - line 6.
607 ########
608 # op.c
609 use warnings 'void' ;
610 "abc"; # OP_CONST
611 7 ; # OP_CONST
612 no warnings 'void' ;
613 "abc"; # OP_CONST
614 7 ; # OP_CONST
615 EXPECT
616 Useless use of a constant in void context at - line 3.
617 Useless use of a constant in void context at - line 4.
618 ########
619 # op.c
620 #
621 use warnings 'misc' ;
622 my $a ; my @a = () ; my %a = () ; my $b = \@a ; my $c = \%a ;
623 @a =~ /abc/ ;
624 @a =~ s/a/b/ ;
625 @a =~ tr/a/b/ ;
626 @$b =~ /abc/ ;
627 @$b =~ s/a/b/ ;
628 @$b =~ tr/a/b/ ;
629 %a =~ /abc/ ;
630 %a =~ s/a/b/ ;
631 %a =~ tr/a/b/ ;
632 %$c =~ /abc/ ;
633 %$c =~ s/a/b/ ;
634 %$c =~ tr/a/b/ ;
635 {
636 no warnings 'misc' ;
637 my $a ; my @a = () ; my %a = () ; my $b = \@a ; my $c = \%a ;
638 @a =~ /abc/ ;
639 @a =~ s/a/b/ ;
640 @a =~ tr/a/b/ ;
641 @$b =~ /abc/ ;
642 @$b =~ s/a/b/ ;
643 @$b =~ tr/a/b/ ;
644 %a =~ /abc/ ;
645 %a =~ s/a/b/ ;
646 %a =~ tr/a/b/ ;
647 %$c =~ /abc/ ;
648 %$c =~ s/a/b/ ;
649 %$c =~ tr/a/b/ ;
650 }
651 EXPECT
652 Applying pattern match (m//) to @array will act on scalar(@array) at - line 5.
653 Applying substitution (s///) to @array will act on scalar(@array) at - line 6.
654 Applying transliteration (tr///) to @array will act on scalar(@array) at - line 7.
655 Applying pattern match (m//) to @array will act on scalar(@array) at - line 8.
656 Applying substitution (s///) to @array will act on scalar(@array) at - line 9.
657 Applying transliteration (tr///) to @array will act on scalar(@array) at - line 10.
658 Applying pattern match (m//) to %hash will act on scalar(%hash) at - line 11.
659 Applying substitution (s///) to %hash will act on scalar(%hash) at - line 12.
660 Applying transliteration (tr///) to %hash will act on scalar(%hash) at - line 13.
661 Applying pattern match (m//) to %hash will act on scalar(%hash) at - line 14.
662 Applying substitution (s///) to %hash will act on scalar(%hash) at - line 15.
663 Applying transliteration (tr///) to %hash will act on scalar(%hash) at - line 16.
664 Can't modify private array in substitution (s///) at - line 6, near "s/a/b/ ;"
665 BEGIN not safe after errors--compilation aborted at - line 18.
666 ########
667 # op.c
668 use warnings 'syntax' ;
669 my $a, $b = (1,2);
670 no warnings 'syntax' ;
671 my $c, $d = (1,2);
672 EXPECT
673 Parentheses missing around "my" list at - line 3.
674 ########
675 # op.c
676 use warnings 'syntax' ;
677 local $a, $b = (1,2);
678 no warnings 'syntax' ;
679 local $c, $d = (1,2);
680 EXPECT
681 Parentheses missing around "local" list at - line 3.
682 ########
683 # op.c
684 use warnings 'bareword' ;
685 print (ABC || 1) ;
686 no warnings 'bareword' ;
687 print (ABC || 1) ;
688 EXPECT
689 Bareword found in conditional at - line 3.
690 ########
691 --FILE-- abc
692
693 --FILE--
694 # op.c
695 use warnings 'misc' ;
696 open FH, "<abc" ;
697 $x = 1 if $x = <FH> ;
698 no warnings 'misc' ;
699 $x = 1 if $x = <FH> ;
700 EXPECT
701 Value of <HANDLE> construct can be "0"; test with defined() at - line 4.
702 ########
703 # op.c
704 use warnings 'misc' ;
705 opendir FH, "." ;
706 $x = 1 if $x = readdir FH ;
707 no warnings 'misc' ;
708 $x = 1 if $x = readdir FH ;
709 closedir FH ;
710 EXPECT
711 Value of readdir() operator can be "0"; test with defined() at - line 4.
712 ########
713 # op.c
714 use warnings 'misc' ;
715 $x = 1 if $x = <*> ;
716 no warnings 'misc' ;
717 $x = 1 if $x = <*> ;
718 EXPECT
719 Value of glob construct can be "0"; test with defined() at - line 3.
720 ########
721 # op.c
722 use warnings 'misc' ;
723 %a = (1,2,3,4) ;
724 $x = 1 if $x = each %a ;
725 no warnings 'misc' ;
726 $x = 1 if $x = each %a ;
727 EXPECT
728 Value of each() operator can be "0"; test with defined() at - line 4.
729 ########
730 # op.c
731 use warnings 'misc' ;
732 $x = 1 while $x = <*> and 0 ;
733 no warnings 'misc' ;
734 $x = 1 while $x = <*> and 0 ;
735 EXPECT
736 Value of glob construct can be "0"; test with defined() at - line 3.
737 ########
738 # op.c
739 use warnings 'misc' ;
740 opendir FH, "." ;
741 $x = 1 while $x = readdir FH and 0 ;
742 no warnings 'misc' ;
743 $x = 1 while $x = readdir FH and 0 ;
744 closedir FH ;
745 EXPECT
746 Value of readdir() operator can be "0"; test with defined() at - line 4.
747 ########
748 # op.c
749 use warnings 'redefine' ;
750 sub fred {}
751 sub fred {}
752 no warnings 'redefine' ;
753 sub fred {}
754 EXPECT
755 Subroutine fred redefined at - line 4.
756 ########
757 # op.c
758 use warnings 'redefine' ;
759 sub fred () { 1 }
760 sub fred () { 1 }
761 no warnings 'redefine' ;
762 sub fred () { 1 }
763 EXPECT
764 Constant subroutine fred redefined at - line 4.
765 ########
766 # op.c
767 no warnings 'redefine' ;
768 sub fred () { 1 }
769 sub fred () { 2 }
770 EXPECT
771 Constant subroutine fred redefined at - line 4.
772 ########
773 # op.c
774 no warnings 'redefine' ;
775 sub fred () { 1 }
776 *fred = sub () { 2 };
777 EXPECT
778 Constant subroutine fred redefined at - line 4.
779 ########
780 # op.c
781 use warnings 'redefine' ;
782 format FRED =
783 .
784 format FRED =
785 .
786 no warnings 'redefine' ;
787 format FRED =
788 .
789 EXPECT
790 Format FRED redefined at - line 5.
791 ########
792 # op.c
793 use warnings 'deprecated' ;
794 push FRED;
795 no warnings 'deprecated' ;
796 push FRED;
797 EXPECT
798 Array @FRED missing the @ in argument 1 of push() at - line 3.
799 ########
800 # op.c
801 use warnings 'deprecated' ;
802 @a = keys FRED ;
803 no warnings 'deprecated' ;
804 @a = keys FRED ;
805 EXPECT
806 Hash %FRED missing the % in argument 1 of keys() at - line 3.
807 ########
808 # op.c
809 use warnings 'syntax' ;
810 exec "$^X -e 1" ; 
811 my $a
812 EXPECT
813 Statement unlikely to be reached at - line 4.
814         (Maybe you meant system() when you said exec()?)
815 ########
816 # op.c
817 use warnings 'deprecated' ;
818 my @a; defined(@a);
819 EXPECT
820 defined(@array) is deprecated at - line 3.
821         (Maybe you should just omit the defined()?)
822 ########
823 # op.c
824 use warnings 'deprecated' ;
825 defined(@a = (1,2,3));
826 EXPECT
827 defined(@array) is deprecated at - line 3.
828         (Maybe you should just omit the defined()?)
829 ########
830 # op.c
831 use warnings 'deprecated' ;
832 my %h; defined(%h);
833 EXPECT
834 defined(%hash) is deprecated at - line 3.
835         (Maybe you should just omit the defined()?)
836 ########
837 # op.c
838 no warnings 'syntax' ;
839 exec "$^X -e 1" ; 
840 my $a
841 EXPECT
842
843 ########
844 # op.c
845 sub fred();
846 sub fred($) {}
847 EXPECT
848 Prototype mismatch: sub main::fred () vs ($) at - line 3.
849 ########
850 # op.c
851 $^W = 0 ;
852 sub fred() ;
853 sub fred($) {}
854 {
855     no warnings 'prototype' ;
856     sub Fred() ;
857     sub Fred($) {}
858     use warnings 'prototype' ;
859     sub freD() ;
860     sub freD($) {}
861 }
862 sub FRED() ;
863 sub FRED($) {}
864 EXPECT
865 Prototype mismatch: sub main::fred () vs ($) at - line 4.
866 Prototype mismatch: sub main::freD () vs ($) at - line 11.
867 Prototype mismatch: sub main::FRED () vs ($) at - line 14.
868 ########
869 # op.c
870 use warnings 'syntax' ;
871 join /---/, 'x', 'y', 'z';
872 EXPECT
873 /---/ should probably be written as "---" at - line 3.
874 ########
875 # op.c [Perl_peep]
876 use warnings 'prototype' ;
877 fred() ; 
878 sub fred ($$) {}
879 no warnings 'prototype' ;
880 joe() ; 
881 sub joe ($$) {}
882 EXPECT
883 main::fred() called too early to check prototype at - line 3.
884 ########
885 # op.c [Perl_newATTRSUB]
886 --FILE-- abc.pm
887 use warnings 'void' ;
888 BEGIN { $| = 1; print "in begin\n"; }
889 CHECK { print "in check\n"; }
890 INIT { print "in init\n"; }
891 END { print "in end\n"; }
892 print "in mainline\n";
893 1;
894 --FILE--
895 use abc;
896 delete $INC{"abc.pm"};
897 require abc;
898 do "abc.pm";
899 EXPECT
900 in begin
901 in mainline
902 in check
903 in init
904 in begin
905 Too late to run CHECK block at abc.pm line 3.
906 Too late to run INIT block at abc.pm line 4.
907 in mainline
908 in begin
909 Too late to run CHECK block at abc.pm line 3.
910 Too late to run INIT block at abc.pm line 4.
911 in mainline
912 in end
913 in end
914 in end
915 ########
916 # op.c [Perl_newATTRSUB]
917 --FILE-- abc.pm
918 no warnings 'void' ;
919 BEGIN { $| = 1; print "in begin\n"; }
920 CHECK { print "in check\n"; }
921 INIT { print "in init\n"; }
922 END { print "in end\n"; }
923 print "in mainline\n";
924 1;
925 --FILE--
926 require abc;
927 do "abc.pm";
928 EXPECT
929 in begin
930 in mainline
931 in begin
932 in mainline
933 in end
934 in end
935 ########
936 # op.c
937 my @x;
938 use warnings 'syntax' ;
939 push(@x);
940 unshift(@x);
941 no warnings 'syntax' ;
942 push(@x);
943 unshift(@x);
944 EXPECT
945 Useless use of push with no values at - line 4.
946 Useless use of unshift with no values at - line 5.
947 ########
948 # op.c
949 use warnings 'deprecated' ;
950 package;
951 no warnings 'deprecated' ;
952 package;
953 EXPECT
954 Use of "package" with no arguments is deprecated at - line 3.
955 Global symbol "BEGIN" requires explicit package name at - line 4.
956 BEGIN not safe after errors--compilation aborted at - line 4.
957 ########
958 # op.c
959 # 20020401 mjd@plover.com at suggestion of jfriedl@yahoo.com
960 use warnings 'regexp';
961 split /blah/g, "blah";
962 no warnings 'regexp';
963 split /blah/g, "blah";
964 EXPECT
965 Use of /g modifier is meaningless in split at - line 4.