Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: A better way for walking through HoHoH ?

by RMGir (Prior)
on Mar 24, 2010 at 13:12 UTC ( #830551=note: print w/ replies, xml ) Need Help??


in reply to A better way for walking through HoHoH ?

Recursion to the rescue! :)

sub handleRefs { my ($target, $keys_ar) = @_; if (ref $target eq "HASH") { foreach my $key(keys %$target) { handleHashOrElement($target->{$key},[@$keys_ar,$key]); } return; } if (ref $target eq "ARRAY") { print "ARRAY at @$keys_ar is [ @$target ]\n"; return; } print "Value at @$keys_ar is $target\n"; } handleRefs(\%rez, []);
In reality, you'd probably pass in another sub reference which would be the action to invoke on the final values.

Mike


Comment on Re: A better way for walking through HoHoH ?
Download Code
Replies are listed 'Best First'.
Re^2: A better way for walking through HoHoH ?
by ZlR (Chaplain) on Mar 24, 2010 at 13:42 UTC
    Ok, so now it really feels like there is a method on an object waiting in the shadow here :D

    I will look at this code more closely when i can !

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (15)
As of 2015-07-29 13:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (263 votes), past polls