📄 perldiag.pod
字号:
=head1 NAMEperldiag - various Perl diagnostics=head1 DESCRIPTIONThese messages are classified as follows (listed in increasing order ofdesperation): (W) A warning (optional). (D) A deprecation (optional). (S) A severe warning (default). (F) A fatal error (trappable). (P) An internal error you should never see (trappable). (X) A very fatal error (nontrappable). (A) An alien error message (not generated by Perl).The majority of messages from the first three classifications above(W, D & S) can be controlled using the C<warnings> pragma. If a message can be controlled by the C<warnings> pragma, its warningcategory is included with the classification letter in the descriptionbelow.Optional warnings are enabled by using the C<warnings> pragma or the B<-w>and B<-W> switches. Warnings may be captured by setting C<$SIG{__WARN__}>to a reference to a routine that will be called on each warning insteadof printing it. See L<perlvar>.Default warnings are always enabled unless they are explicitly disabledwith the C<warnings> pragma or the B<-X> switch.Trappable errors may be trapped using the eval operator. SeeL<perlfunc/eval>. In almost all cases, warnings may be selectivelydisabled or promoted to fatal errors using the C<warnings> pragma.See L<warnings>.The messages are in alphabetical order, without regard to upper orlower-case. Some of these messages are generic. Spots that vary aredenoted with a %s or other printf-style escape. These escapes areignored by the alphabetical order, as are all characters other thanletters. To look up your message, just ignore anything that is not aletter.=over 4=item accept() on closed socket %s(W closed) You tried to do an accept on a closed socket. Did you forgetto check the return value of your socket() call? SeeL<perlfunc/accept>.=item Allocation too large: %lx(X) You can't allocate more than 64K on an MS-DOS machine.=item '!' allowed only after types %s(F) The '!' is allowed in pack() and unpack() only after certain types.See L<perlfunc/pack>.=item Ambiguous call resolved as CORE::%s(), qualify as such or use &(W ambiguous) A subroutine you have declared has the same name as a Perlkeyword, and you have used the name without qualification for callingone or the other. Perl decided to call the builtin because thesubroutine is not imported.To force interpretation as a subroutine call, either put an ampersandbefore the subroutine name, or qualify the name with its package.Alternatively, you can import the subroutine (or pretend that it'simported with the C<use subs> pragma).To silently interpret it as the Perl operator, use the C<CORE::> prefixon the operator (e.g. C<CORE::log($x)>) or by declaring the subroutineto be an object method (see L<perlsub/"Subroutine Attributes"> orL<attributes>).=item Ambiguous use of %s resolved as %s(W ambiguous)(S) You said something that may not be interpreted the wayyou thought. Normally it's pretty easy to disambiguate it by supplyinga missing quote, operator, parenthesis pair or declaration.=item '|' and '<' may not both be specified on command line(F) An error peculiar to VMS. Perl does its own command lineredirection, and found that STDIN was a pipe, and that you also tried toredirect STDIN using '<'. Only one STDIN stream to a customer, please.=item '|' and '>' may not both be specified on command line(F) An error peculiar to VMS. Perl does its own command lineredirection, and thinks you tried to redirect stdout both to a file andinto a pipe to another command. You need to choose one or the other,though nothing's stopping you from piping into a program or Perl scriptwhich 'splits' output into two streams, such as open(OUT,">$ARGV[0]") or die "Can't write to $ARGV[0]: $!"; while (<STDIN>) { print; print OUT; } close OUT;=item Applying %s to %s will act on scalar(%s)(W misc) The pattern match (//), substitution (s///), andtransliteration (tr///) operators work on scalar values. If you applyone of them to an array or a hash, it will convert the array or hash toa scalar value -- the length of an array, or the population info of ahash -- and then work on that scalar value. This is probably not whatyou meant to do. See L<perlfunc/grep> and L<perlfunc/map> foralternatives.=item Args must match #! line(F) The setuid emulator requires that the arguments Perl was invokedwith match the arguments specified on the #! line. Since some systemsimpose a one-argument limit on the #! line, try combining switches;for example, turn C<-w -U> into C<-wU>.=item Arg too short for msgsnd(F) msgsnd() requires a string at least as long as sizeof(long).=item %s argument is not a HASH or ARRAY element(F) The argument to exists() must be a hash or array element, such as: $foo{$bar} $ref->{"susie"}[12]=item %s argument is not a HASH or ARRAY element or slice(F) The argument to delete() must be either a hash or array element,such as: $foo{$bar} $ref->{"susie"}[12]or a hash or array slice, such as: @foo[$bar, $baz, $xyzzy] @{$ref->[12]}{"susie", "queue"}=item %s argument is not a subroutine name(F) The argument to exists() for C<exists &sub> must be a subroutinename, and not a subroutine call. C<exists &sub()> will generate thiserror.=item Argument "%s" isn't numeric%s(W numeric) The indicated string was fed as an argument to an operatorthat expected a numeric value instead. If you're fortunate the messagewill identify which operator was so unfortunate.=item Array @%s missing the @ in argument %d of %s()(D deprecated) Really old Perl let you omit the @ on array names in somespots. This is now heavily deprecated.=item assertion botched: %s(P) The malloc package that comes with Perl had an internal failure.=item Assertion failed: file "%s"(P) A general assertion failed. The file in question must be examined.=item Assignment to both a list and a scalar(F) If you assign to a conditional operator, the 2nd and 3rd argumentsmust either both be scalars or both be lists. Otherwise Perl won'tknow which context to supply to the right side.=item Negative offset to vec in lvalue context(F) When vec is called in an lvalue context, the second argument must begreater than or equal to zero.=item Attempt to free non-arena SV: 0x%lx(P internal) All SV objects are supposed to be allocated from arenasthat will be garbage collected on exit. An SV was discovered to beoutside any of those arenas.=item Attempt to free nonexistent shared string(P internal) Perl maintains a reference counted internal table ofstrings to optimize the storage and access of hash keys and otherstrings. This indicates someone tried to decrement the reference countof a string that can no longer be found in the table.=item Attempt to free temp prematurely(W debugging) Mortalized values are supposed to be freed by thefree_tmps() routine. This indicates that something else is freeing theSV before the free_tmps() routine gets a chance, which means that thefree_tmps() routine will be freeing an unreferenced scalar when it doestry to free it.=item Attempt to free unreferenced glob pointers(P internal) The reference counts got screwed up on symbol aliases.=item Attempt to free unreferenced scalar(W internal) Perl went to decrement the reference count of a scalar tosee if it would go to 0, and discovered that it had already gone to 0earlier, and should have been freed, and in fact, probably was freed.This could indicate that SvREFCNT_dec() was called too many times, orthat SvREFCNT_inc() was called too few times, or that the SV wasmortalized when it shouldn't have been, or that memory has beencorrupted.=item Attempt to join self(F) You tried to join a thread from within itself, which is animpossible task. You may be joining the wrong thread, or you may needto move the join() to some other thread.=item Attempt to pack pointer to temporary value(W pack) You tried to pass a temporary value (like the result of afunction, or a computed expression) to the "p" pack() template. Thismeans the result contains a pointer to a location that could becomeinvalid anytime, even before the end of the current statement. Useliterals or global values as arguments to the "p" pack() template toavoid this warning.=item Attempt to use reference as lvalue in substr(W substr) You supplied a reference as the first argument to substr()used as an lvalue, which is pretty strange. Perhaps you forgot todereference it first. See L<perlfunc/substr>.=item Bad arg length for %s, is %d, should be %d(F) You passed a buffer of the wrong size to one of msgctl(), semctl()or shmctl(). In C parlance, the correct sizes are, respectively,S<sizeof(struct msqid_ds *)>, S<sizeof(struct semid_ds *)>, andS<sizeof(struct shmid_ds *)>.=item Bad evalled substitution pattern(F) You've used the /e switch to evaluate the replacement for asubstitution, but perl found a syntax error in the code to evaluate,most likely an unexpected right brace '}'.=item Bad filehandle: %s(F) A symbol was passed to something wanting a filehandle, but thesymbol has no filehandle associated with it. Perhaps you didn't do anopen(), or did it in another package.=item Bad free() ignored(S malloc) An internal routine called free() on something that had neverbeen malloc()ed in the first place. Mandatory, but can be disabled bysetting environment variable C<PERL_BADFREE> to 0.This message can be seen quite often with DB_File on systems with "hard"dynamic linking, like C<AIX> and C<OS/2>. It is a bug of C<Berkeley DB>which is left unnoticed if C<DB> uses I<forgiving> system malloc().=item Bad hash(P) One of the internal hash routines was passed a null HV pointer.=item Bad index while coercing array into hash(F) The index looked up in the hash found as the 0'th element of apseudo-hash is not legal. Index values must be at 1 or greater.See L<perlref>.=item Badly placed ()'s(A) You've accidentally run your script through B<csh> insteadof Perl. Check the #! line, or manually feed your script intoPerl yourself.=item Bad name after %s::(F) You started to name a symbol by using a package prefix, and thendidn't finish the symbol. In particular, you can't interpolate outsideof quotes, so $var = 'myvar'; $sym = mypack::$var;is not the same as $var = 'myvar'; $sym = "mypack::$var";=item Bad realloc() ignored(S malloc) An internal routine called realloc() on something that hadnever been malloc()ed in the first place. Mandatory, but can be disabledby setting environment variable C<PERL_BADFREE> to 1.=item Bad symbol for array(P) An internal request asked to add an array entry to something thatwasn't a symbol table entry.=item Bad symbol for filehandle(P) An internal request asked to add a filehandle entry to somethingthat wasn't a symbol table entry.=item Bad symbol for hash(P) An internal request asked to add a hash entry to something thatwasn't a symbol table entry.=item Bareword found in conditional(W bareword) The compiler found a bareword where it expected aconditional, which often indicates that an || or && was parsed as partof the last argument of the previous construct, for example: open FOO || die;It may also indicate a misspelled constant that has been interpreted asa bareword: use constant TYPO => 1; if (TYOP) { print "foo" }The C<strict> pragma is useful in avoiding such errors.=item Bareword "%s" not allowed while "strict subs" in use(F) With "strict subs" in use, a bareword is only allowed as asubroutine identifier, in curly brackets or to the left of the "=>"symbol. Perhaps you need to predeclare a subroutine?=item Bareword "%s" refers to nonexistent package(W bareword) You used a qualified bareword of the form C<Foo::>, but thecompiler saw no other uses of that namespace before that point. Perhapsyou need to predeclare a package?=item BEGIN failed--compilation aborted(F) An untrapped exception was raised while executing a BEGINsubroutine. Compilation stops immediately and the interpreter isexited.=item BEGIN not safe after errors--compilation aborted(F) Perl found a C<BEGIN {}> subroutine (or a C<use> directive, whichimplies a C<BEGIN {}>) after one or more compilation errors had alreadyoccurred. Since the intended environment for the C<BEGIN {}> could notbe guaranteed (due to the errors), and since subsequent code likelydepends on its correct operation, Perl just gave up.=item \1 better written as $1(W syntax) Outside of patterns, backreferences live on as variables.The use of backslashes is grandfathered on the right-hand side of a
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -