Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
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 surveying the Monastery: (4)
As of 2024-09-15 06:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    The PerlMonks site front end has:





    Results (21 votes). Check out past polls.

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.