fsavigny has asked for the wisdom of the Perl Monks concerning the following question:
No, I am all but sure I am NOT the person who has discovered an undocumented feature - but still, I have not found this explained in either Programming Perl or the perldata manpage:
Is it a reliable feature of Perl that if you assign to a key more than once in one list, then the latest overwrites any previous ones? I do not mean single assignments in $hash{foo} = 4 style, but when this occurs in a list:
%hash = ( foo => 3, bar => 2, foo => 1, foo => 10); print join " ", %hash, "\n"; # outputs: bar 2 foo 10
Any other experiments I've run have also made it seem as if the last assignment overwrites anything before it. Is this documented anywhere? It looks to me as if it could be interesting as a method of changing several values at once.
Best regards, Florian
|
|---|