I am going to keep my question high level, because that is me, that is my style, and that is what I need answer for.
I have a multi-level hash to work with (hash of hashes). I also have algorithms that give me a sequence of keys in @key (to various values to look up).
My technique to access individual values is:
Simply build an expression looking like
$h-> {$key[0] }=> {$key[1]} => ... e.t.c.
and then "eval" that expression.
Are there better techniques to deal with variable key sequences, without eval?
( The hash is a mirror of a directory structure. Values are individual files, and my program needs to read the content of those files.)
I tried and it works with the eval option.
Data::Diver makes this easy.
You can use
${ DiveRef( ... ) }instead ofDiveVal.You could also use the following:
You can use
${ dive_ref( ... ) }instead ofdive_val.dive_refcan be adapted to create a data structure from a file tree.