in reply to Tie::Hash::MultiValue Unique question
Welcome to the Monastery.
I apologize if I misinterpret your question. It's usually a good idea to provide sample data for what you want to do in order to clarify your question. See I know what I mean. Why don't you?.
Fundamental to the hash data structure is a unique key for every entry. Therefore, it is impossible to have a key occur more than once for the hash. If you attempt to store a key-value pair more that once, it will overwrite the old value with the new one, but there will still only be one occurrence of the key.
If, on the other hand, you are trying to check if a value already exists in a hash, that is answered in a faq. Assuming your data is in a hash named %hash, you could check if the value in $value already exists with the code:
my %reverse_hash = reverse %hash; if (not exists $reverse_hash{$value}) { $hash{$key} = $value; }
You could express that much more succinctly, but I expect that would confuse the issue. There are a few other ways I could think of interpreting your question, and so if these explanations do not answer your specific question, please provide some more specificity.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Tie::Hash::MultiValue Unique question
by elsubliminal (Initiate) on Apr 17, 2009 at 20:56 UTC | |
by FunkyMonk (Bishop) on Apr 17, 2009 at 23:38 UTC | |
by kennethk (Abbot) on Apr 17, 2009 at 21:01 UTC | |
by elsubliminal (Initiate) on Apr 17, 2009 at 21:10 UTC | |
by ikegami (Patriarch) on Apr 17, 2009 at 23:54 UTC | |
by elsubliminal (Initiate) on Apr 18, 2009 at 07:15 UTC | |
| |
by AnomalousMonk (Archbishop) on Apr 17, 2009 at 22:53 UTC | |
by ikegami (Patriarch) on Apr 17, 2009 at 23:47 UTC |