Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: "Dynamically" Accessing a HoH

by dave0 (Friar)
on Jun 02, 2005 at 15:03 UTC ( [id://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?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (6)
As of 2024-04-18 01:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found