Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: "Dynamically" Accessing a HoH

by ysth (Canon)
on Jun 02, 2005 at 15:39 UTC ( #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
Node Status?
node history
Node Type: note [id://462953]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2021-06-20 21:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What does the "s" stand for in "perls"? (Whence perls)












    Results (95 votes). Check out past polls.

    Notices?