Recursive to check same key in has

S

Siratinee Sukachai

h1 = {project=>{opp=>{Index=>{title=>Opportunities}}}}
h2 = {project=>{opp=>{Index=>{link=>Report}}}}

I need to check same key in hash and group the value to assign to the
same key of hash. How to do that?
 
B

Brian Candler

This is a case where recursion may be helpful.

However, based on your other posting, I think you may be trying to solve
the wrong problem.

If you're trying to combine

project.opp.Index.title=Opportunities
project.opp.Index.link=Report

into a single nested hash, then you don't need to build separate nested
hashes and then combine them. I think it would be easier to build the
final hash up-front, as you read in each new line.

Of course, doing a deep-merge of a nested hash structure is an
interesting exercise, or homework problem :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,796
Messages
2,569,645
Members
45,369
Latest member
Carmen32T6

Latest Threads

Top