in reply to Dynamic Dereferencing
# Convert a . to }->{ in order for meta.created to look like meta}->{created $element =~ s/\./}->{/g; # This works for all elements except of meta}->{created $deref = $item->{$element}; print "Convert: \$item->{" . $element . "}\t\t\t" . $deref . "\n"; }
I think you are trying to achieve something with a sort of "meta-coding" which is quite dangerous: when you write $item->{$element} you're try to access the hash $item value with a key like "...}->{..." which is why you then get that error, because there isn't such a key!
If you really want to do such a sort of meta-coding, then you need to write for instance "$item->{".$element."}" and then you can try to eval() that thing. Why instead not trying one of the modules recommended by haukex ?
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Dynamic Dereferencing
by Anonymous Monk on Dec 07, 2018 at 12:25 UTC | |
by markong (Pilgrim) on Dec 07, 2018 at 14:41 UTC |