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