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