📄 op
字号:
use warnings 'misc' ;my $a ; my @a = () ; my %a = () ; my $b = \@a ; my $c = \%a ;@a =~ /abc/ ;@a =~ s/a/b/ ;@a =~ tr/a/b/ ;@$b =~ /abc/ ;@$b =~ s/a/b/ ;@$b =~ tr/a/b/ ;%a =~ /abc/ ;%a =~ s/a/b/ ;%a =~ tr/a/b/ ;%$c =~ /abc/ ;%$c =~ s/a/b/ ;%$c =~ tr/a/b/ ;{no warnings 'misc' ;my $a ; my @a = () ; my %a = () ; my $b = \@a ; my $c = \%a ;@a =~ /abc/ ;@a =~ s/a/b/ ;@a =~ tr/a/b/ ;@$b =~ /abc/ ;@$b =~ s/a/b/ ;@$b =~ tr/a/b/ ;%a =~ /abc/ ;%a =~ s/a/b/ ;%a =~ tr/a/b/ ;%$c =~ /abc/ ;%$c =~ s/a/b/ ;%$c =~ tr/a/b/ ;}EXPECTApplying pattern match (m//) to @array will act on scalar(@array) at - line 5.Applying substitution (s///) to @array will act on scalar(@array) at - line 6.Applying transliteration (tr///) to @array will act on scalar(@array) at - line 7.Applying pattern match (m//) to @array will act on scalar(@array) at - line 8.Applying substitution (s///) to @array will act on scalar(@array) at - line 9.Applying transliteration (tr///) to @array will act on scalar(@array) at - line 10.Applying pattern match (m//) to %hash will act on scalar(%hash) at - line 11.Applying substitution (s///) to %hash will act on scalar(%hash) at - line 12.Applying transliteration (tr///) to %hash will act on scalar(%hash) at - line 13.Applying pattern match (m//) to %hash will act on scalar(%hash) at - line 14.Applying substitution (s///) to %hash will act on scalar(%hash) at - line 15.Applying transliteration (tr///) to %hash will act on scalar(%hash) at - line 16.Can't modify private array in substitution (s///) at - line 6, near "s/a/b/ ;"BEGIN not safe after errors--compilation aborted at - line 18.######### op.cuse warnings 'parenthesis' ;my $a, $b = (1,2);my @foo,%bar, $quux; # there's a TAB heremy $x, $y or print;no warnings 'parenthesis' ;my $c, $d = (1,2);EXPECTParentheses missing around "my" list at - line 3.Parentheses missing around "my" list at - line 4.######### op.cuse warnings 'parenthesis' ;our $a, $b = (1,2);no warnings 'parenthesis' ;our $c, $d = (1,2);EXPECTParentheses missing around "our" list at - line 3.######### op.cuse warnings 'parenthesis' ;local $a, $b = (1,2);local *f, *g;no warnings 'parenthesis' ;local $c, $d = (1,2);EXPECTParentheses missing around "local" list at - line 3.Parentheses missing around "local" list at - line 4.######### op.cuse warnings 'bareword' ;print (ABC || 1) ;no warnings 'bareword' ;print (ABC || 1) ;EXPECTBareword found in conditional at - line 3.########--FILE-- abc--FILE--# op.cuse warnings 'misc' ;open FH, "<abc" ;$x = 1 if $x = <FH> ;no warnings 'misc' ;$x = 1 if $x = <FH> ;EXPECTValue of <HANDLE> construct can be "0"; test with defined() at - line 4.######### op.cuse warnings 'misc' ;opendir FH, "." ;$x = 1 if $x = readdir FH ;no warnings 'misc' ;$x = 1 if $x = readdir FH ;closedir FH ;EXPECTValue of readdir() operator can be "0"; test with defined() at - line 4.######### op.cuse warnings 'misc' ;$x = 1 if $x = <*> ;no warnings 'misc' ;$x = 1 if $x = <*> ;EXPECTValue of glob construct can be "0"; test with defined() at - line 3.######### op.cuse warnings 'misc' ;%a = (1,2,3,4) ;$x = 1 if $x = each %a ;no warnings 'misc' ;$x = 1 if $x = each %a ;EXPECTValue of each() operator can be "0"; test with defined() at - line 4.######### op.cuse warnings 'misc' ;$x = 1 while $x = <*> and 0 ;no warnings 'misc' ;$x = 1 while $x = <*> and 0 ;EXPECTValue of glob construct can be "0"; test with defined() at - line 3.######### op.cuse warnings 'misc' ;opendir FH, "." ;$x = 1 while $x = readdir FH and 0 ;no warnings 'misc' ;$x = 1 while $x = readdir FH and 0 ;closedir FH ;EXPECTValue of readdir() operator can be "0"; test with defined() at - line 4.######### op.cuse warnings 'misc';open FH, "<abc";($_ = <FH>) // ($_ = 1);opendir DH, ".";%a = (1,2,3,4) ;EXPECT######### op.cuse warnings 'redefine' ;sub fred {}sub fred {}no warnings 'redefine' ;sub fred {}EXPECTSubroutine fred redefined at - line 4.######### op.cuse warnings 'redefine' ;sub fred () { 1 }sub fred () { 1 }no warnings 'redefine' ;sub fred () { 1 }EXPECTConstant subroutine fred redefined at - line 4.######### op.cno warnings 'redefine' ;sub fred () { 1 }sub fred () { 2 }EXPECTConstant subroutine fred redefined at - line 4.######### op.cno warnings 'redefine' ;sub fred () { 1 }*fred = sub () { 2 };EXPECTConstant subroutine main::fred redefined at - line 4.######### op.cuse warnings 'redefine' ;format FRED =.format FRED =.no warnings 'redefine' ;format FRED =.EXPECTFormat FRED redefined at - line 5.######### op.cuse warnings 'deprecated' ;push FRED;no warnings 'deprecated' ;push FRED;EXPECTArray @FRED missing the @ in argument 1 of push() at - line 3.######### op.cuse warnings 'deprecated' ;@a = keys FRED ;no warnings 'deprecated' ;@a = keys FRED ;EXPECTHash %FRED missing the % in argument 1 of keys() at - line 3.######### op.cBEGIN { if ($^O eq 'MacOS') { print <<EOM;SKIPPED# no exec on Mac OSEOM exit; }}use warnings 'syntax' ;exec "$^X -e 1" ; my $aEXPECTStatement unlikely to be reached at - line 13. (Maybe you meant system() when you said exec()?)######### op.cuse warnings 'deprecated' ;my @a; defined(@a);EXPECTdefined(@array) is deprecated at - line 3. (Maybe you should just omit the defined()?)######### op.cuse warnings 'deprecated' ;defined(@a = (1,2,3));EXPECTdefined(@array) is deprecated at - line 3. (Maybe you should just omit the defined()?)######### op.cuse warnings 'deprecated' ;my %h; defined(%h);EXPECTdefined(%hash) is deprecated at - line 3. (Maybe you should just omit the defined()?)######### op.cBEGIN { if ($^O eq 'MacOS') { print <<EOM;SKIPPED# no exec on Mac OSEOM exit; }}no warnings 'syntax' ;exec "$^X -e 1" ; my $aEXPECT######### op.csub fred();sub fred($) {}EXPECTPrototype mismatch: sub main::fred () vs ($) at - line 3.######### op.c$^W = 0 ;sub fred() ;sub fred($) {}{ no warnings 'prototype' ; sub Fred() ; sub Fred($) {} use warnings 'prototype' ; sub freD() ; sub freD($) {}}sub FRED() ;sub FRED($) {}EXPECTPrototype mismatch: sub main::fred () vs ($) at - line 4.Prototype mismatch: sub main::freD () vs ($) at - line 11.Prototype mismatch: sub main::FRED () vs ($) at - line 14.######### op.cuse warnings 'syntax' ;join /---/, 'x', 'y', 'z';EXPECT/---/ should probably be written as "---" at - line 3.######### op.c [Perl_peep]use warnings 'prototype' ;fred() ; sub fred ($$) {}no warnings 'prototype' ;joe() ; sub joe ($$) {}EXPECTmain::fred() called too early to check prototype at - line 3.######### op.c [Perl_newATTRSUB]--FILE-- abc.pmuse warnings 'void' ;BEGIN { $| = 1; print "in begin\n"; }CHECK { print "in check\n"; }INIT { print "in init\n"; }END { print "in end\n"; }print "in mainline\n";1;--FILE--use abc;delete $INC{"abc.pm"};require abc;do "abc.pm";EXPECTin beginin mainlinein checkin initin beginToo late to run CHECK block at abc.pm line 3.Too late to run INIT block at abc.pm line 4.in mainlinein beginToo late to run CHECK block at abc.pm line 3.Too late to run INIT block at abc.pm line 4.in mainlinein endin endin end######### op.c [Perl_newATTRSUB]--FILE-- abc.pmno warnings 'void' ;BEGIN { $| = 1; print "in begin\n"; }CHECK { print "in check\n"; }INIT { print "in init\n"; }END { print "in end\n"; }print "in mainline\n";1;--FILE--require abc;do "abc.pm";EXPECTin beginin mainlinein beginin mainlinein endin end######### op.cmy @x;use warnings 'syntax' ;push(@x);unshift(@x);no warnings 'syntax' ;push(@x);unshift(@x);EXPECTUseless use of push with no values at - line 4.Useless use of unshift with no values at - line 5.######### op.c# 20020401 mjd@plover.com at suggestion of jfriedl@yahoo.comuse warnings 'regexp';split /blah/g, "blah";no warnings 'regexp';split /blah/g, "blah";EXPECTUse of /g modifier is meaningless in split at - line 4.######### op.cuse warnings 'precedence';$a = $b & $c == $d;$a = $b ^ $c != $d;$a = $b | $c > $d;$a = $b < $c & $d;$a = $b >= $c ^ $d;$a = $b <= $c | $d;$a = $b <=> $c & $d;$a &= $b == $c; $a |= $b == $c; $a ^= $b == $c; # shouldn't warnno warnings 'precedence';$a = $b & $c == $d;$a = $b ^ $c != $d;$a = $b | $c > $d;$a = $b < $c & $d;$a = $b >= $c ^ $d;$a = $b <= $c | $d;$a = $b <=> $c & $d;EXPECTPossible precedence problem on bitwise & operator at - line 3.Possible precedence problem on bitwise ^ operator at - line 4.Possible precedence problem on bitwise | operator at - line 5.Possible precedence problem on bitwise & operator at - line 6.Possible precedence problem on bitwise ^ operator at - line 7.Possible precedence problem on bitwise | operator at - line 8.Possible precedence problem on bitwise & operator at - line 9.######### op.cuse integer;use warnings 'precedence';$a = $b & $c == $d;$a = $b ^ $c != $d;$a = $b | $c > $d;$a = $b < $c & $d;$a = $b >= $c ^ $d;$a = $b <= $c | $d;$a = $b <=> $c & $d;no warnings 'precedence';$a = $b & $c == $d;$a = $b ^ $c != $d;$a = $b | $c > $d;$a = $b < $c & $d;$a = $b >= $c ^ $d;$a = $b <= $c | $d;$a = $b <=> $c & $d;EXPECTPossible precedence problem on bitwise & operator at - line 4.Possible precedence problem on bitwise ^ operator at - line 5.Possible precedence problem on bitwise | operator at - line 6.Possible precedence problem on bitwise & operator at - line 7.Possible precedence problem on bitwise ^ operator at - line 8.Possible precedence problem on bitwise | operator at - line 9.Possible precedence problem on bitwise & operator at - line 10.######### op.c# ok => local() has desired effect;# ignore=> local() silently ignoreduse warnings 'syntax';local(undef); # OP_UNDEF ignoresub lval : lvalue {};local(lval()); # OP_ENTERSUBlocal($x **= 1); # OP_POWlocal($x *= 1); # OP_MULTIPLYlocal($x /= 1); # OP_DIVIDElocal($x %= 1); # OP_MODULOlocal($x x= 1); # OP_REPEATlocal($x += 1); # OP_ADDlocal($x -= 1); # OP_SUBTRACTlocal($x .= 1); # OP_CONCATlocal($x <<= 1); # OP_LEFT_SHIFTlocal($x >>= 1); # OP_RIGHT_SHIFTlocal($x &= 1); # OP_BIT_ANDlocal($x ^= 1); # OP_BIT_XORlocal($x |= 1); # OP_BIT_OR{ use integer; local($x *= 1); # OP_I_MULTIPLY local($x /= 1); # OP_I_DIVIDE local($x %= 1); # OP_I_MODULO local($x += 1); # OP_I_ADD local($x -= 1); # OP_I_SUBTRACT}local($x?$y:$z) = 1; # OP_COND_EXPR ok# these two are fatal run-time errors instead#local(@$a); # OP_RV2AV ok#local(%$a); # OP_RV2HV oklocal(*a); # OP_RV2GV oklocal(@a[1,2]); # OP_ASLICE oklocal(@a{1,2}); # OP_HSLICE oklocal(@a = (1,2)); # OP_AASSIGNlocal($$x); # OP_RV2SV oklocal($#a); # OP_AV2ARYLENlocal($x = 1); # OP_SASSIGNlocal($x &&= 1); # OP_ANDASSIGNlocal($x ||= 1); # OP_ORASSIGNlocal($x //= 1); # OP_DORASSIGNlocal($a[0]); # OP_AELEMFAST oklocal(substr($x,0,1)); # OP_SUBSTRlocal(pos($x)); # OP_POSlocal(vec($x,0,1)); # OP_VEClocal($a[$b]); # OP_AELEM oklocal($a{$b}); # OP_HELEM oklocal($[); # OP_CONSTno warnings 'syntax';EXPECTUseless localization of subroutine entry at - line 10.Useless localization of exponentiation (**) at - line 11.Useless localization of multiplication (*) at - line 12.Useless localization of division (/) at - line 13.Useless localization of modulus (%) at - line 14.Useless localization of repeat (x) at - line 15.Useless localization of addition (+) at - line 16.Useless localization of subtraction (-) at - line 17.Useless localization of concatenation (.) or string at - line 18.Useless localization of left bitshift (<<) at - line 19.Useless localization of right bitshift (>>) at - line 20.Useless localization of bitwise and (&) at - line 21.Useless localization of bitwise xor (^) at - line 22.Useless localization of bitwise or (|) at - line 23.Useless localization of integer multiplication (*) at - line 26.Useless localization of integer division (/) at - line 27.Useless localization of integer modulus (%) at - line 28.Useless localization of integer addition (+) at - line 29.Useless localization of integer subtraction (-) at - line 30.Useless localization of list assignment at - line 39.Useless localization of array length at - line 41.Useless localization of scalar assignment at - line 42.Useless localization of logical and assignment (&&=) at - line 43.Useless localization of logical or assignment (||=) at - line 44.Useless localization of defined or assignment (//=) at - line 45.Useless localization of substr at - line 48.Useless localization of match position at - line 49.Useless localization of vec at - line 50.######### op.cuse warnings 'deprecated';my $x1 if 0;my @x2 if 0;my %x3 if 0;my ($x4) if 0;my ($x5,@x6, %x7) if 0;0 && my $z1;0 && my (%z2);# these shouldn't warnour $x if 0;our $x unless 0;if (0) { my $w1 }if (my $w2) { $a=1 }if ($a && (my $w3 = 1)) {$a = 2}EXPECTDeprecated use of my() in false conditional at - line 3.Deprecated use of my() in false conditional at - line 4.Deprecated use of my() in false conditional at - line 5.Deprecated use of my() in false conditional at - line 6.Deprecated use of my() in false conditional at - line 7.Deprecated use of my() in false conditional at - line 8.Deprecated use of my() in false conditional at - line 9.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -