Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: "Dynamically" Accessing a HoH

by ysth (Canon)
on Jun 02, 2005 at 15:39 UTC ( [id://462953]=note: print w/replies, xml ) Need Help??


in reply to "Dynamically" Accessing a HoH

To make merlyn happy:

Why not just keep using eval, but validate your $usr_str?

die "horribly" if $usr_str !~ /^(\{\w+\})+\z/; my $val = eval "\$xml->$usr_str"; print $val;
If you do change to parsing out string keys and looping through them, which is really easy to do as others have demonstrated, be aware that some things will actually work differently, e.g. $usr_str = "{0x2a}{052}", which with eval is equivalent to {42}{42}.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (7)
As of 2024-04-25 15:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found