Checking, I find that perl5.004 appears to throw away the last key whenever a hash is initialised from a list with an odd number of elements, whereas perl5.004_05 and later act as if there were an extra undef at the end of the list to make it even.
As a result, %a = (1, 2, 3) leaves %a containing one key ('1') in perl5.004 and two keys ('1', '3') in newer perls. I guess this came in as a bug fix sometime after the initial perl5.004 release, but I don't know exactly when, and I don't have any of the intermediate versions to check.
Even perl5.004 warns "Odd number of elements in hash list", so this is just another reason always to turn on warnings. :)
Hugo
In reply to Re: Construction/initialisation of empty hash
by hv
in thread Construction/initialisation of empty hash
by muntfish
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |