diff options
author | Lukas Mai <l.mai@web.de> | 2012-04-02 19:27:46 +0200 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2012-05-21 17:51:54 -0700 |
commit | c9e3649f13e1c1db9054c8d419ce2969309e093d (patch) | |
tree | fd59793a2e17206871a30663608d1f40b1c454ae | |
parent | c673b32a53b02a8de2ced7b6a7b5705866b64ebb (diff) | |
download | perl-c9e3649f13e1c1db9054c8d419ce2969309e093d.tar.gz |
document behavior of duplicate keys in hash assignment
-rw-r--r-- | pod/perldata.pod | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/pod/perldata.pod b/pod/perldata.pod index 977c0e09a2..8611d3d2b2 100644 --- a/pod/perldata.pod +++ b/pod/perldata.pod @@ -666,6 +666,29 @@ Note that just because a hash is initialized in that order doesn't mean that it comes out in that order. See L<perlfunc/sort> for examples of how to arrange for an output ordering. +If a key appears more than once in the initializer list of a hash, the last +occurrence wins: + + %circle = ( + center => [5, 10], + center => [27, 9], + radius => 100, + color => [0xDF, 0xFF, 0x00], + radius => 54, + ); + + # same as + %circle = ( + center => [27, 9], + color => [0xDF, 0xFF, 0x00], + radius => 54, + ); + +This can be used to provide overridable configuration defaults: + + # values in %args take priority over %config_defaults + %config = (%config_defaults, %args); + =head2 Subscripts An array can be accessed one scalar at a |