Use of uninitialized value: when don't you get that?



I like to have "use strict" and "use warnings" (actually, "-w" on my
scripts). I'm now wondering: when can you use an undefined value and
not get the "Use of uninitialized value" warning. Experimentally, I
don't get the warning with

my $x = undef;
my $y = undef;
if ($y) { ... }
if (! $y) { ... }
if ($y && ! $y) { ... }
if (exists $x->{notdef}) { ... }
if (defined $x->{notdef}) { ... }
if ($x->{notdef}) { ... }
# and none of those autovivify it.

(at least under Perl 5.008008, which is what my workplace uses).

Is there a more complete listing of conditions that cause the warning
and/or those that do not? I consider "using the value" to be an
insufficient explantion, because I consider "if ($y)" to be a use of
the value. "Using the value with an operator" covers cases like "+"
and "." and "eq", but it doesn't work for me because "&&" is an
operator too.

--
Tim McDaniel, tmcd@xxxxxxxxx
.



Relevant Pages

  • Re: why wont perl say which value was uninitialized?
    ... who did a half-assed implementation of a warning for situation ... Then what should print do with an undef ... warning which happen to exist' (in a suitable version of perl), ... doesn't *necessarily* indicate an exceptional condition ...
    (comp.lang.perl.misc)
  • Re: why wont perl say which value was uninitialized?
    ... a half-assed implementation of a warning for situation which is ... Then what should print do with an undef argument? ... what it is supposed to do: Print nothing aka 'an empty string'. ... doesn't *necessarily* indicate an exceptional condition ...
    (comp.lang.perl.misc)
  • Re: [RegEx] Optional parameter
    ... variables start out with a value of 'undef' and this will be ... my $foo = undef; ... for cases where the intent is that $foo should be assigned a new value before ... are going to happen silently and which are going to trigger the warning. ...
    (comp.lang.perl.misc)
  • Re: why wont perl say which value was uninitialized?
    ... What is the basis for your assertion that the scalar representing 'an ... doesn't *necessarily* indicate an exceptional condition ... Note that since "undef" is a valid scalar, ... does in fact trigger a warning. ...
    (comp.lang.perl.misc)
  • Re: why wont perl say which value was uninitialized?
    ... Judgeing from the output ('uninitialized value' as opposed to 'undef ... Would you be satisified if the warning said "undefined value" rather ... One is to quietly treat the argument as an empty string. ... of us has an ironclad argument about how it *should* behave. ...
    (comp.lang.perl.misc)