http://qs321.pair.com?node_id=580490


in reply to seeking in hash data structure

There's a fairly simple algorithm to do this that you can write if you understand how recursion and references work. Your function starts with a reference to the root of the hash, the value to add once you find the right node, and a list of keys to find that node. Shift the first keys from the list and look up that entry in the hash, which gives you a hashref. Call the function again recursively with this new hashref, the same value to add, and the remaining keys. Once there are no more keys, you can add the value to the hashref you have, which will point to the right position in the tree. Use a syntax like $hashref = $hashref->{key} to go down to the next level in the hash. By "non strict references" I assume you meant symbolic references, the ones you can't use with use strict. And no, those won't work, because the hashes are anonymous.

Replies are listed 'Best First'.
Re^2: seeking in hash data structure
by Maze (Sexton) on Oct 26, 2006 at 21:55 UTC
    That is a skillfull method my esteemed monk, but for laziness sake the perl module Data::Diver and the -numerous- SQL interfaces that i've now looked up seem to be the ticket, I think that for practices sake I may write up that algorithm my self, if I get round to it.