# New Ticket Created by Brendan Byrd # Please include the string: [perl #94972] # in the subject line of all future correspondence about this issue. # <URL: https://rt.perl.org:443/rt3/Ticket/Display.html?id=94972 > Traditionally, Perl has maintained their version of the NULL value = undef. This aspect of variables needs to be expanded on, but potentially new changes may take a step backwards: exists may also be called on array elements, but its behavior is much less obvious and is strongly tied to the use of delete<http://perldoc.perl.org/functions/delete.html>on arrays. * Be aware that calling exists on array values is deprecated and likely to be removed in a future version of Perl.* There's a need for variables to exist in a state of "initialized, but undefined". All variables, not just hashes. And these states need to be detectable as "initialized, but undefined". As in "my container's value is undefined, but my container still exists." Zero-like values like '' or 0 are different than NULL or undef. Instead of removing functionality from the 'exists' function, it should be expanded to work on scalars, arrays, hashes, code containers, references, even globs and filehandles. If the behavior of undef doesn't work in all cases, then that should be fixed as well: $aaa = undef; # initialized, but undefined undef $bbb; # removes the container, so the variable is now uninitialized $ccc[4] = undef; # initialized, but undefined (even if it's the last one in the array) $ddd{'key'} = undef; # initialized, but undefined $ddd{undef} = undef; # still valid $ccc[undef] = undef; # illegal (undef isn't a number) undef $ccc[4]; # either illegal or works like splice undef $ddd{'key'}; # either illegal or works like delete exists $aaa && !defined $aaa; # true for both exists $ccc[4] && !defined $ccc[4]; # true for both exists $ddd{'key'} && !defined $ddd{'key'}; # true for both In other words, the left side and the right side of undef should work differently. Making something undefined and undefining something are two different things. -- Brendan Byrd/SineSwiper <SineSwiper@GMail.com> Computer tech, PERL wizard, and all-around Internet guruThread Previous | Thread Next