Skip to content

Commit 7eab72f

Browse files
committed
perldiag: Clarify uninit diagnostic explanation
Most of the text for this change was contributed by Tony Cook
1 parent 4f5164a commit 7eab72f

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

pod/perldiag.pod

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7971,14 +7971,24 @@ and their use is legal.
79717971

79727972
=item Use of uninitialized value%s
79737973

7974-
(W uninitialized) An undefined value was used as if it were already
7975-
defined. It was interpreted as a "" or a 0, but maybe it was a mistake.
7976-
To suppress this warning assign a defined value to your variables.
7974+
(W uninitialized) An undefined value was used in a context where the
7975+
value has meaning, for example as a number, string or reference. It was
7976+
interpreted as an empty string or zero.
7977+
7978+
If you didn't expect this value to be undefined, you can initialise the
7979+
value before using it. If you expected the value could be undefined and
7980+
want to suppress this particular instance of the warning, you can use the
7981+
L<C<E<sol>E<sol>>|perlop/C-style Logical Or, Xor, and Defined Or>
7982+
(defined-or) operator to provide an alternative that takes effect only
7983+
when the value is undefined.
7984+
7985+
Otherwise if you don't care about undefined values you can disable this
7986+
warning.
79777987

79787988
To help you figure out what was undefined, perl will try to tell you
79797989
the name of the variable (if any) that was undefined. In some cases
79807990
it cannot do this, so it also tells you what operation you used the
7981-
undefined value in. Note, however, that perl optimizes your program
7991+
undefined value in. Note, however, that perl optimizes your program,
79827992
and the operation displayed in the warning may not necessarily appear
79837993
literally in your program. For example, C<"that $foo"> is usually
79847994
optimized into C<"that " . $foo>, and the warning will refer to the

pod/perlop.pod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1043,6 +1043,7 @@ without the need for parentheses.
10431043
X<||> X<operator, logical, or>
10441044
X<^^> X<operator, logical, xor>
10451045
X<//> X<operator, logical, defined-or>
1046+
X<//> X<operator, logical, dor>
10461047

10471048
Binary C<"||"> performs a short-circuit logical OR operation. That is,
10481049
if the left operand is true, the right operand is not even evaluated.

0 commit comments

Comments
 (0)