Sharan Basappa <sharan.basa...@gmail.com> asked: > Can someone tell me how to convert an array to hash. > > Each array entry has a row of values > e.g. a(0) = ab cd ef; a(1) = mn de fg > > The hash array needs to be constructed with one of the element in the > array row as the key. > e.g. hash{ab} = cd ef - ab is a string in the array row > hash{mn} = de fg - mn is a string in the array row > > Can someone comment?
This works in the obvious way (pseudocode): for each element in the source array: compute the hash key from the element compute the hash value that should be stored under that key if the hash key doesn't exist yet store the hash value otherwise handle duplicate hash key Which part is it that is giving you trouble? HTH, Thomas -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/