in reply to "Dynamically" Accessing a HoH
If you want the user to be able to enter their key in the format of "{depTar}{name}", it should just be a simple matter of parsing to convert that into single keys for hash access.my $user_str_toplevel = 'depTar'; my $user_str_secondlevel = 'name'; my $xml = { 'depTar' => { 'name' => 'c_p20', 'loc' => 'srvr1' }}; print $xml->{$user_str_toplevel}{$user_str_secondlevel};
Given that your source format is XML, XML::XPath might be worth looking at instead.
|
---|