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