Mailing List Archive

Odd numbers of elements in hash (Perl bug NETaa14645). Was: Re: Diff two arrays.
[Cced to perlbug]

In article <46902i$98u@gateway.grumman.com>,
John Allen <allen@gateway.grumman.com> wrote:
>In article <ukybug7mjn.fsf@linda.teleport.com>,
>Randal L. Schwartz <merlyn@stonehenge.com> wrote:
>>>>>>> "Todd" == Todd Beverly <tb@vegas.kodak.com> writes:

>>Todd> %mark = [];

>>You have just created an associative array with one element whose key
>>is the stringificiation of the reference to an anonymous list, and value
>>is undef.

>I think he just created an empty associative array.
> perl -e '%a = []; print keys %a'

> prints nothing

>Isn't this because valueless keys are not added to a hash?

No, it's a bug in Perl, NETaa14645, unresolved as at 7 September (which
is when Tom stopped updating the bugs database on www.perl.com).

http://mox.perl.com/perl/bugs/NETaa14645-1.html

contains Gurusamy Sarathy's report, and includes a patch.

I note that it (the patch) reports both "Odd number of elements in hash
list" and "Attempt to use reference as hash key" using warn(), although
they are documented as (S) and (W). Some reconsistencification needed
here, methinks. IMO, those levels are right, although it would be nice
to be able to use refs as hash keys one day.

Ian