Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: "Dynamically" Accessing a HoH

by dave0 (Friar)
on Jun 02, 2005 at 15:03 UTC ( #462946=note: print w/replies, xml ) Need Help??


in reply to "Dynamically" Accessing a HoH

Why not just use normal 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};
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.

Given that your source format is XML, XML::XPath might be worth looking at instead.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://462946]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (4)
As of 2021-10-23 21:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My first memorable Perl project was:







    Results (88 votes). Check out past polls.

    Notices?