in reply to Adding data to hashes & comparing
I'm not entirely sure, but I have the feeling you could do better with fewer lists and more hashes. In my experience, the only time a list/array is better than a hash is if the order of the items is important and you really don't have a usable key OR you're making a hash where multiple items have the same key, in which case you might want to use a hash of lists. Certainly, if you're going to search for items in the data structure, use a a hash. If you want to make a list of things and later check if something is in that list, don't make it with an array, make it with a hash where all the values are just 1, or something like that. It's easier and faster. I'm sure that's a massive overgeneralization.
I don't know how many times I've said "Okay, this should really be a list" and then later turned it into a hash.
Instead of making a list of all your hashes, make a hash and use the value you want to compare as the key. Then you can just do something like if ( $hash_1{$foo} eq $hash_2{$foo} )....
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Adding data to hashes & comparing
by hallikpapa (Scribe) on Mar 31, 2009 at 15:52 UTC | |
by pileofrogs (Priest) on Apr 02, 2009 at 16:32 UTC |