Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!jarthur!uunet!convex!usenet From: tchrist@convex.COM (Tom Christiansen) Newsgroups: comp.lang.perl Subject: Re: A question on associative arrays Message-ID: <1991May30.205555.14490@convex.com> Date: 30 May 91 20:55:55 GMT References: Sender: usenet@convex.com (news access account) Reply-To: tchrist@convex.COM (Tom Christiansen) Organization: CONVEX Software Development, Richardson, TX Lines: 23 Nntp-Posting-Host: pixel.convex.com From the keyboard of przemek@rrdstrad.nist.gov (Przemek Klosowski): :Hello! :The solution to a problem with testing if associative array element :was already defined reminded me of a problem I had, and couldn't figure :out. How does one check if the associative array was assigned at all? :My program runs a loop initializing an array, but each individual :initialization is conditioned on something. On a rainy day all conditions :could be false: is there a way to find out? The obvious $#ary doesn't work, :since it refers to @ary. defined(%ary) is no good, since %ary might be :pre-defined in a local(). Ideas, anyone? if (%a) { will actually work, but I don't think that Larry has ever documented this. More portably, and more slowly would be if (@my_keys = keys %a) { --tom -- Tom Christiansen tchrist@convex.com convex!tchrist "So much mail, so little time."