in reply to "Dynamically" Accessing a HoH
If I were a user, I'd be annoyed by that format for $usr_string, so I'm going to assume you're not tied to it, and can have them supply something (slightly) more intuitive like depTar/name instead.
Using the power of unjustified assumptions makes coding much easier, you see... <grin>
my @keys = split '/', $usr_string; my $ref = $xml; $ref = $ref->{$_} for @keys; print $ref;
Obviously, this completely fails to check for error conditions of any kind (invalid keys owing to typos being the most obvious case). I'm assuming you know how to do that already. :-)
If God had meant us to fly, he would *never* have given us the railroads.
--Michael Flanders
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: "Dynamically" Accessing a HoH
by dave0 (Friar) on Jun 02, 2005 at 16:26 UTC |
In Section
Seekers of Perl Wisdom