Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: How to find all occurrences of a key in a deeply nested structure?

by moritz (Cardinal)
on Oct 20, 2011 at 14:29 UTC ( [id://932681]=note: print w/replies, xml ) Need Help??


in reply to How to find all occurrences of a key in a deeply nested structure?

What have you tried?

I'd write a subroutine that receives a hash ref as an argument, and stores the right value if the key in question is there. Then it recurses into all the values that are hashrefs.

  • Comment on Re: How to find all occurrences of a key in a deeply nested structure?

Replies are listed 'Best First'.
Re^2: How to find all occurrences of a key in a deeply nested structure?
by deMize (Monk) on Oct 20, 2011 at 14:58 UTC
    First: I'm not sure why asking a valid question is worth -1 rep, but I guess that's someone's opinion. Anyhow, Tye came out with Data::Diver, so I was hoping there would be an easier way than to build my own recursive "find" tool. I can see how to set values with his module, but not sure how to scan for all occurrences.


    Demize
      It's worth -1 because we're not here to do all your work - or your homework! - for you. We can help you more if you show us what you've already tried and explain how its results differ from what you expected.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (3)
As of 2024-04-20 01:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found