So I just started using Perl, and I had to write a database for a website. I still don't know a lot about Perl, but with what I knew the best way to do it was with a bunch of hashes. That way I had links, and the categories of links all organized neatly. I accomplished this by creating pointers which pointer to other pointers and so on until they pointed to hashes ( a sort of hash of hashes of hashes etc.)
I am tired of manually updating this database and have endeavored into writing an editing perl script. I am stuck on how to edit the actual data structure. Here is a general idea of how it looks like and my problem
$A = {
B => {
1 => bla,
2 => bla,
3 => bla
},
C => null,
D => {
52 => bla,
53 => bla
}
}
My problem is encountered when I try to change "C" and make it point to not a value but a hash or list. I know have to reinitialize C => {} then $A->{$C}->{$23} = bla. To do my add method, I take in two parameters, the location which is $a->{$c} and the key,data set ($23, bla.) I want to make this dynamic so if $a originally points to null, I want to be able to take the location that was passed in, $a->{$c}, and try to make that key data set, if I can't make it check if $c points to a hash or value, if it doesn't exist, go back to $a and see if that points to a hash and if it doesn't make it point to a hash, then i will be able to add the desired data.
I have the idea in my head, I just can't figure out a way to go backwards through the references (ie given a final location break that location up and go from the front, or take the final location apart part by part from the back)
I am about to resort to passing in the location as a string, breaking up the string, and getting breaking it up that way.
Sorry if this is confusing I tried to simplify it out because at this point my data structure is pretty ... pointee.