in reply to "Dynamically" Accessing a HoH


the 1st post would do it if you always only have two keys, if an unknown number of keys can be given try this...

#!/usr/bin/perl use strict; use warnings; my $usr_str = "{depTar}{name}"; my @keys = $usr_str =~ m/\{(.*?)\}/g; my $xml = { 'depTar' => { 'name' => 'c_p20', 'loc' => 'srvr1' }}; my $href = $xml; for my $i (0 .. $#keys) { $href = $href->{$keys[$i]}; }; print $href;



Update: fixed spelling mistake

This is not a Signature...