T
Tim McDaniel
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.
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.