in reply to Swapping Two Hash Values
Hashes can have duplicate VALUES, but not duplicate KEYS. You assigned a value to the key of '', probably because your assignment statement's left side's key expression evaluated to undef. (Undef stringizes as ''.)
I shouldn't scan so quickly, the odd values-first printout threw me off. However, this should explain your odd "duplicate keys" mystery.
%hash = ( '1' => 'angel', '2' => 'buffy', '3' => 'cordelia', '4' => 'dawn', '5' => 'ethan' '54' => undef, '6' => 'faith', '7' => 'giles', );
The printf "%d" turned the key '5 4' into an integer '5'.
--
[ e d @ h a l l e y . c c ]
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Swapping Two Hash Values
by Cody Pendant (Prior) on May 28, 2003 at 00:44 UTC | |
by sauoq (Abbot) on May 28, 2003 at 00:48 UTC |