Problems? Is your data what you think it is? | |
PerlMonks |
Re^4: When DOESN'T "Use of uninitialized value" show up?by Tim McDaniel (Novice) |
on Dec 16, 2011 at 22:25 UTC ( [id://944021]=note: print w/replies, xml ) | Need Help?? |
It's true that having more warnings may turn people off and cause them to turn warnings off. Someone in my office did that right now, and I think it was for no warnings 'uninitialized'. Nevertheless, I don't often use uninitialized values as actual values, and when I do, I check for it being !defined before using it further. So I want more restrictions on the use of uninitialized values. I would prefer if all arithmetic on undef values threw a warning, for example, or use in a boolean context.
Thank you for pointing out defined(): since it's defined to deal with undef, certainly it should not throw a warning with undef! Similarly with //, and exists is arguably in the same class. However, "my $x = undef" is equivalent to "my $x" or even "undef my $x". And I don't consider "my $x = 123;" to use undef at all: in this context, you can't tell that $x was ever assigned undef, and even if it was, that value is never referenced but is instead stomped out of existence. In C, the term I'm looking for is "rvalue": I would like warnings whenever I try to access the value of undef. Thank you for the pointer to "no autovivification;" I don't know any details about autovivification and I need to look it up.
In Section
Seekers of Perl Wisdom
|
|