This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
perldiag: ‘Unbalanced saves’ is a default warning
[perl5.git] / pod / perldiag.pod
index 31ce464..7ee49b7 100644 (file)
@@ -135,20 +135,6 @@ string C<"-foo">, or a call to the function C<foo>, negated.  If you meant
 the string, just write C<"-foo">.  If you meant the function call,
 write C<-foo()>.
 
-=item Ambiguous use of 's//le...' resolved as 's// le...'; Rewrite as 's//el' if you meant 'use locale rules and evaluate rhs as an expression'.  In Perl 5.18, it will be resolved the other way
-
-(W deprecated, ambiguous) You wrote a pattern match with substitution
-immediately followed by "le".  In Perl 5.16 and earlier, this is
-resolved as meaning to take the result of the substitution, and see if
-it is stringwise less-than-or-equal-to what follows in the expression.
-Having the "le" immediately following a pattern is deprecated behavior,
-so in Perl 5.18, this expression will be resolved as meaning to do the
-pattern match using the rules of the current locale, and evaluate the
-rhs as an expression when doing the substitution.  In 5.14, and 5.16 if
-you want the latter interpretation, you can simply write "el" instead.
-But note that the C</l> modifier should not be used explicitly anyway;
-you should use C<use locale> instead.  See L<perllocale>.
-
 =item '|' and '<' may not both be specified on command line
 
 (F) An error peculiar to VMS.  Perl does its own command line
@@ -359,9 +345,10 @@ L<perlvar/%INC>.
 
 =item Attempt to set length of freed array
 
-(W) You tried to set the length of an array which has been freed.  You
-can do this by storing a reference to the scalar representing the last index
-of an array and later assigning through that reference.  For example
+(W misc) You tried to set the length of an array which has
+been freed.  You can do this by storing a reference to the
+scalar representing the last index of an array and later
+assigning through that reference.  For example
 
     $r = do {my @a; \$#a};
     $$r = 503
@@ -1808,13 +1795,13 @@ single form when it must operate on them directly.  Either you've passed
 an invalid file specification to Perl, or you've found a case the
 conversion routines don't handle.  Drat.
 
-=item %s: Eval-group in insecure regular expression
+=item Eval-group in insecure regular expression
 
 (F) Perl detected tainted data when trying to compile a regular
 expression that contains the C<(?{ ... })> zero-width assertion, which
 is unsafe.  See L<perlre/(?{ code })>, and L<perlsec>.
 
-=item %s: Eval-group not allowed at runtime, use re 'eval'
+=item Eval-group not allowed at runtime, use re 'eval' in regex m/%s/
 
 (F) Perl tried to compile a regular expression containing the
 C<(?{ ... })> zero-width assertion at run time, as it would when the
@@ -1824,7 +1811,7 @@ C<re 'eval'> pragma or by explicitly building the pattern from an
 interpolated string at run time and using that in an eval().  See
 L<perlre/(?{ code })>.
 
-=item %s: Eval-group not allowed, use re 'eval'
+=item Eval-group not allowed, use re 'eval' in regex m/%s/
 
 (F) A regular expression contained the C<(?{ ... })> zero-width
 assertion, but that construct is only allowed when the C<use re 'eval'>
@@ -2091,6 +2078,12 @@ has since been undefined.
 (F) A ()-group started with a count.  A count is supposed to follow
 something: a template character or a ()-group.  See L<perlfunc/pack>.
 
+=item Group name must start with a non-digit word character in regex; marked by <-- HERE in m/%s/
+
+(F) Group names must follow the rules for perl identifiers, meaning
+they must start with a non-digit word character. A common cause of
+this error is using (?&0) instead of (?0). See L<perlre>.
+
 =item %s had compilation errors.
 
 (F) The final summary message when a C<perl -c> fails.
@@ -2111,33 +2104,22 @@ spots.  This is now heavily deprecated.
 (F) The parser has given up trying to parse the program after 10 errors.
 Further error messages would likely be uninformative.
 
-=item Having no space between pattern and following word is deprecated
-
-(D syntax)
-
-You had a word that isn't a regex modifier immediately following
-a pattern without an intervening space.  If you are trying to use
-the C</le> flags on a substitution, use C</el> instead.  Otherwise, add
-white space between the pattern and following word to eliminate
-the warning.  As an example of the latter, the two constructs:
-
-
- $a =~ m/$foo/sand $bar
- $a =~ m/$foo/s and $bar
-
-both currently mean the same thing, but it is planned to disallow
-the first form in Perl 5.18.  And,
-
- $a =~ m/$foo/and $bar
-
-will be disallowed too.
-
 =item Hexadecimal number > 0xffffffff non-portable
 
 (W portable) The hexadecimal number you specified is larger than 2**32-1
 (4294967295) and therefore non-portable between systems.  See
 L<perlport> for more on portability concerns.
 
+=item -i used with no filenames on the command line, reading from STDIN
+
+(S inplace) The C<-i> option was passed on the command line, indicating
+that the script is intended to edit files inplace, but no files were
+given.  This is usually a mistake, since editing STDIN inplace doesn't
+make sense, and can be confusing because it can make perl look like
+it is hanging when it is really just trying to read from STDIN.  You
+should either pass a filename to edit, or remove C<-i> from the command
+line.  See L<perlrun> for more details.
+
 =item Identifier too long
 
 (F) Perl limits identifiers (names for variables, functions, etc.) to
@@ -2318,7 +2300,7 @@ integers for your architecture.
 
 =item Integer overflow in %s number
 
-(W overflow) The hexadecimal, octal or binary number you have specified
+(S overflow) The hexadecimal, octal or binary number you have specified
 either as a literal or as an argument to hex() or oct() is too big for
 your architecture, and has been converted to a floating point number.
 On a 32-bit architecture the largest hexadecimal, octal or binary number
@@ -2328,14 +2310,24 @@ transparently promotes all numbers to a floating point representation
 internally--subject to loss of precision errors in subsequent
 operations.
 
+=item Integer overflow in srand
+
+(S overflow) The number you have passed to srand is too big to fit
+in your architecture's integer representation.  The number has been
+replaced with the largest integer supported (0xFFFFFFFF on 32-bit
+architectures).  This means you may be getting less randomness than
+you expect, because different random seeds above the maximum will
+return the same sequence of random numbers.
+
 =item Integer overflow in version
 
-(F) Some portion of a version initialization is too large for the
-size of integers for your architecture.  This is not a warning
-because there is no rational reason for a version to try and use a
-element larger than typically 2**32.  This is usually caused by
-trying to use some odd mathematical operation as a version, like
-100/9.
+=item Integer overflow in version %d
+
+(W overflow) Some portion of a version initialization is too large for
+the size of integers for your architecture.  This is not a warning
+because there is no rational reason for a version to try and use an
+element larger than typically 2**32.  This is usually caused by trying
+to use some odd mathematical operation as a version, like 100/9.
 
 =item Internal disaster in regex; marked by <-- HERE in m/%s/
 
@@ -2391,6 +2383,8 @@ escape was discovered.
 
 =item Invalid hexadecimal number in \N{U+...}
 
+=item Invalid hexadecimal number in \N{U+...} in regex; marked by <-- HERE in m/%s/
+
 (F) The character constant represented by C<...> is not a valid hexadecimal
 number.  Either it is empty, or you tried to use a character other than
 0 - 9 or A - F, a - f in a hexadecimal number.
@@ -2409,6 +2403,12 @@ where C<foo> is not a valid method resolution order (MRO).  Currently,
 the only valid ones supported are C<dfs> and C<c3>, unless you have loaded
 a module that is a MRO plugin.  See L<mro> and L<perlmroapi>.
 
+=item Invalid negative number (%s) in chr
+
+(W utf8) You passed a negative number to C<chr>.  Negative numbers are
+not valid characters numbers, so it return the Unicode replacement
+character (U+FFFD).
+
 =item invalid option -D%c, use -D'' to see choices
 
 (F) Perl was called with invalid debugger flags.  Call perl with
@@ -2528,7 +2528,7 @@ an anonymous subroutine, or a reference to a subroutine.
 (W overload) You tried to overload a constant type the overload package is
 unaware of.
 
-=item junk on end of regexp
+=item Junk on end of regexp in regex m/%s/
 
 (P) The regular expression parser is confused.
 
@@ -2781,6 +2781,8 @@ immediately after the switch, without intervening spaces.
 
 =item Missing braces on \N{}
 
+=item Missing braces on \N{} in regex; marked by <-- HERE in m/%s/
+
 (F) Wrong syntax of character name literal C<\N{charname}> within
 double-quotish context.  This can also happen when there is a space
 (or comment) between the C<\N> and the C<{> in a regex with the C</x> modifier.
@@ -2823,7 +2825,7 @@ can vary from one line to the next.
 (S syntax) This is an educated guess made in conjunction with the message
 "%s found where operator expected".  Often the missing operator is a comma.
 
-=item Missing right brace on %s
+=item Missing right brace on \%c{} in regex; marked by <-- HERE in m/%s/
 
 (F) Missing right brace in C<\x{...}>, C<\p{...}>, C<\P{...}>, or C<\N{...}>.
 
@@ -2950,14 +2952,14 @@ NOTE: This warning detects symbols that have been used only once so $c, @c,
 the same; if a program uses $c only once but also uses any of the others it
 will not trigger this warning.
 
-=item \N in a character class must be a named character: \N{...}
+=item \N in a character class must be a named character: \N{...} in regex; marked by <-- HERE in m/%s/
 
 (F) The new (5.12) meaning of C<\N> as C<[^\n]> is not valid in a bracketed
 character class, for the same reason that C<.> in a character class loses
 its specialness: it matches almost everything, which is probably not
 what you want.
 
-=item \N{NAME} must be resolved by the lexer
+=item \N{NAME} must be resolved by the lexer in regex; marked by <-- HERE in m/%s/
 
 (F) When compiling a regex pattern, an unresolved named character or
 sequence was encountered.  This can happen in any of several ways that
@@ -3186,11 +3188,6 @@ subroutine), but found a reference to something else instead.  You can
 use the ref() function to find out what kind of ref it really was.  See
 also L<perlref>.
 
-=item Not a format reference
-
-(F) I'm not sure how you managed to generate a reference to an anonymous
-format, but this indicates you did, and that it didn't exist.
-
 =item Not a GLOB reference
 
 (F) Perl was trying to evaluate a reference to a "typeglob" (that is, a
@@ -3693,6 +3690,12 @@ then discovered it wasn't a subroutine or eval context.
 
 (P) scan_num() got called on something that wasn't a number.
 
+=item panic: Sequence (?{...}): no code block found
+
+(P) while compiling a pattern that has embedded (?{}) or (??{}) code
+blocks, perl couldn't locate the code block that should have already been
+seen and compiled by perl before control passed to the regex compiler.
+
 =item panic: sv_chop %s
 
 (P) The sv_chop() routine was passed a position that is not within the
@@ -4152,7 +4155,7 @@ to use parens.  In any case, a hash requires key/value B<pairs>.
 (W misc) You have attempted to weaken a reference that is already weak.
 Doing so has no effect.
 
-=item Reference to invalid group 0
+=item Reference to invalid group 0 in regex; marked by <-- HERE in m/%s/
 
 (F) You used C<\g0> or similar in a regular expression.  You may refer
 to capturing parentheses only with strictly positive integers
@@ -4200,7 +4203,7 @@ expression compiler gave it.
 (F syntax, regexp) The regular expression pattern had too many occurrences
 of the specified modifier.  Remove the extraneous ones.
 
-=item Regexp modifier "%c" may not appear after the "-"
+=item Regexp modifier "%c" may not appear after the "-" in regex; marked by <-- HERE in m/%s/
 
 (F regexp) Turning off the given modifier has the side effect of turning
 on another one.  Perl currently doesn't allow this.  Reword the regular
@@ -4213,7 +4216,7 @@ the minus), instead of the one you want to turn off.
 mutually exclusive modifiers.  Retain only the modifier that is
 supposed to be there.
 
-=item Regexp out of space
+=item Regexp out of space in regex m/%s/
 
 (P) A "can't happen" error, because safemalloc() should have caught it
 earlier.
@@ -4242,10 +4245,11 @@ really a dirhandle.  Check your control flow.
 
 =item Scalars leaked: %d
 
-(P) Something went wrong in Perl's internal bookkeeping of scalars:
-not all scalar variables were deallocated by the time Perl exited.
-What this usually indicates is a memory leak, which is of course bad,
-especially if the Perl program is intended to be long-running.
+(W internal) Something went wrong in Perl's internal bookkeeping
+of scalars: not all scalar variables were deallocated by the time
+Perl exited.  What this usually indicates is a memory leak, which
+is of course bad, especially if the Perl program is intended to be
+long-running.
 
 =item Scalar value @%s[%s] better written as $%s[%s]
 
@@ -4362,19 +4366,16 @@ causes, see L<perlre>.
 (F) The regular expression expects a mandatory argument following the escape
 sequence and this has been omitted or incorrectly written.
 
-=item Sequence (?#... not terminated in regex; marked by <-- HERE in m/%s/
+=item Sequence (?#... not terminated in regex m/%s/
 
 (F) A regular expression comment must be terminated by a closing
-parenthesis.  Embedded parentheses aren't allowed.  The <-- HERE shows in
-the regular expression about where the problem was discovered.  See
+parenthesis.  Embedded parentheses aren't allowed.  See
 L<perlre>.
 
-=item Sequence (?{...}) not terminated or not {}-balanced in regex; marked by <-- HERE in m/%s/
+=item Sequence (?{...}) not terminated with ')'
 
-(F) If the contents of a (?{...}) clause contain braces, they
-must balance for Perl to detect the end of the clause properly.
-The <-- HERE shows in the regular expression about where the
-problem was discovered.  See L<perlre>.
+(F) The end of the perl code contained within the {...} must be
+followed immediately by a ')'.
 
 =item Z<>500 Server error
 
@@ -4857,10 +4858,6 @@ was not a reference to an unblessed hash or array.
 (F) Your machine doesn't implement the umask function and you tried to
 use it to restrict permissions for yourself (EXPR & 0700).
 
-=item Unable to create sub named "%s"
-
-(F) You attempted to create or access a subroutine with an illegal name.
-
 =item Unbalanced context: %d more PUSHes than POPs
 
 (W internal) The exit code detected an internal inconsistency in how
@@ -4868,12 +4865,12 @@ many execution contexts were entered and left.
 
 =item Unbalanced saves: %d more saves than restores
 
-(W internal) The exit code detected an internal inconsistency in how
+(S internal) The exit code detected an internal inconsistency in how
 many values were temporarily localized.
 
 =item Unbalanced scopes: %d more ENTERs than LEAVEs
 
-(W internal) The exit code detected an internal inconsistency in how
+(S internal) The exit code detected an internal inconsistency in how
 many blocks were entered and left.
 
 =item Unbalanced string table refcount: (%d) for "%s"
@@ -5004,6 +5001,21 @@ subvert Perl's population of %ENV for nefarious purposes.
 
 (W) You tried to use an unknown subpragma of the "re" pragma.
 
+=item Unknown regex modifier "%s"
+
+(F) Alphanumerics immediately following the closing delimiter
+of a regular expression pattern are interpreted by Perl as modifier
+flags for the regex.  One of the ones you specified is invalid.  One way
+this can happen is if you didn't put in white space between the end of
+the regex and a following alphanumeric operator:
+
+ if ($a =~ /foo/and $bar == 3) { ... }
+
+The C<"a"> is a valid modifier flag, but the C<"n"> is not, and raises
+this error.  Likely what was meant instead was:
+
+ if ($a =~ /foo/ and $bar == 3) { ... }
+
 =item Unknown switch condition (?(%s in regex; marked by <-- HERE in m/%s/
 
 (F) The condition part of a (?(condition)if-clause|else-clause) construct
@@ -5047,14 +5059,16 @@ Note that if you want to enable a warnings category registered by a
 module (e.g. C<use warnings 'File::Find'>), you must have loaded this
 module first.
 
-=item unmatched [ in regex; marked by <-- HERE in m/%s/
+=item Unmatched [ in regex; marked by <-- HERE in m/%s/
 
 (F) The brackets around a character class must match.  If you wish to
 include a closing bracket in a character class, backslash it or put it
 first.  The <-- HERE shows in the regular expression about where the
 problem was discovered.  See L<perlre>.
 
-=item unmatched ( in regex; marked by <-- HERE in m/%s/
+=item Unmatched ( in regex; marked by <-- HERE in m/%s/
+
+=item Unmatched ) in regex; marked by <-- HERE in m/%s/
 
 (F) Unbackslashed parentheses must always be balanced in regular
 expressions.  If you're a vi user, the % key is valuable for finding
@@ -5468,17 +5482,6 @@ will be available for use in new operators in the future.  Write C<m?\w?>
 instead, explicitly using the C<m> operator: the question mark delimiter
 still invokes match-once behaviour.
 
-=item Use of qw(...) as parentheses is deprecated
-
-(D deprecated) You have something like C<foreach $x qw(a b c) {...}>,
-using a C<qw(...)> list literal where a parenthesised expression is
-expected.  Historically the parser fooled itself into thinking that
-C<qw(...)> literals were always enclosed in parentheses, and as a result
-you could sometimes omit parentheses around them.  (You could never do
-the C<foreach qw(a b c) {...}> that you might have expected, though.)
-The parser no longer lies to itself in this way.  Wrap the list literal
-in parentheses, like C<foreach $x (qw(a b c)) {...}>.
-
 =item Use of reference "%s" as array index
 
 (W misc) You tried to use a reference as an array index; this probably
@@ -5608,13 +5611,13 @@ executed, so its $a is not available for capture.
 
 =item Variable "%s" is not imported%s
 
-(W misc) With "use strict" in effect, you referred to a global variable
+(S misc) With "use strict" in effect, you referred to a global variable
 that you apparently thought was imported from another module, because
 something else of the same name (usually a subroutine) is exported by
 that module.  It usually means you put the wrong funny character on the
 front of your variable.
 
-=item Variable length lookbehind not implemented in m/%s/
+=item Variable length lookbehind not implemented in regex m/%s/
 
 (F) Lookbehind is allowed only for subexpressions whose length is fixed and
 known at compile time.  See L<perlre>.