[comp.lang.perl] defined keys that aren't defined

tchrist@convex.com (Tom Christiansen) (12/17/90)

I know this is beating a dead horse, and we're still waiting
for Larry to emerge from his sequesterment to actually comment
on this stuff, but I just discovered a pretty (to me) counter-
intuitive implication that I wanted to add.

    @x{'a'..'g'} = ();
    print("keys are: ", join(", ", sort keys %x), "\n");
    print((defined $x{'c'}) ? "defined" : "not defined", "\n");

This prints "not defined".  Keys claims that there's a "c" element, 
but defined says otherwise.  This seems inconsistent.  I'm still 
looking for a useful application of this phenomenon.

--tom
--
Tom Christiansen		tchrist@convex.com	convex!tchrist
"With a kernel dive, all things are possible, but it sure makes it hard
 to look at yourself in the mirror the next morning."  -me

allbery@NCoast.ORG (Brandon S. Allbery KB8JRR) (12/19/90)

As quoted from <111562@convex.convex.com> by tchrist@convex.com (Tom Christiansen):
+---------------
|     @x{'a'..'g'} = ();
|     print("keys are: ", join(", ", sort keys %x), "\n");
|     print((defined $x{'c'}) ? "defined" : "not defined", "\n");
| 
| This prints "not defined".  Keys claims that there's a "c" element, 
| but defined says otherwise.  This seems inconsistent.  I'm still 
| looking for a useful application of this phenomenon.
+---------------

Symbol tables.  You've seen symbol "c", but you don't know what its value is
yet.  (Come to think of it, isn't this used in the current implementation of
packages?)

++Brandon
-- 
Me: Brandon S. Allbery			    VHF/UHF: KB8JRR on 220, 2m, 440
Internet: allbery@NCoast.ORG		    Packet: KB8JRR @ WA8BXN
America OnLine: KB8JRR			    AMPR: KB8JRR.AmPR.ORG [44.70.4.88]
uunet!usenet.ins.cwru.edu!ncoast!allbery    Delphi: ALLBERY