Hello Uri, Thanks for the explanation. I figured this out once I ran the code where I got this doubt. The reason why I raised this question is that languages like C++ do allow hashes arrays that can have different values but same key. Thats the reason for the second part of my question.
Regards, Sharan On Mon, Aug 2, 2010 at 3:36 PM, Uri Guttman <[email protected]> wrote: >>>>>> "SB" == Sharan Basappa <[email protected]> writes: > > SB> Is there any restriction that the keys in perl should be unique? > SB> If not, are there any special considerations that need to be kept > SB> in mind while accessing the elements? > > well, think about it first. what would happen if a hash allowed > duplicate keys? how would you know which associated value was attached > to the duplicate key? the whole point of hashes is to index by a > string. requiring unique keys is what makes it a hash. in a similar vein > what would happen if you could index an array multiple times with the > same integer? it makes no sense. same for hashes. > > uri > > -- > Uri Guttman ------ [email protected] -------- http://www.sysarch.com -- > ----- Perl Code Review , Architecture, Development, Training, Support ------ > --------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com --------- > -- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected] http://learn.perl.org/
