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
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.