Solved

mapping the two resultssets in Perl

Posted on 2009-07-15
2
161 Views
Last Modified: 2012-05-07
I am getting two resultsets I want to group the results togther from both the results mapping on the id column which is present in bothe the results and display the results
0
Comment
Question by:saibsk
2 Comments
 
LVL 13

Accepted Solution

by:
Carl Bohman earned 500 total points
ID: 24862562
Your description is very vague.  What do the result sets look like?  Are they file?  Are they arrays or hashes?  What type of output are you looking for?

The general approach is to use a hash with a unique key.  Something like the following (which assumes that the data is in two hashes where the key is the id and the value is the data).
foreach (keys %ResultSet1)

{

 push @{$FinalResult{$_}}, $ResultSet1{$_};

}

foreach (keys %ResultSet2)

{

 push @{$FinalResult{$_}}, $ResultSet2{$_};

}

foreach (keys %FinalResult)

{

 print join(" \n", $_, @{$FinalResult{$_}}), "\n";

}

Open in new window

0
 
LVL 9

Expert Comment

by:Suhas .
ID: 24866303
can you share the two sample result sets...
that will be easier for us to understand and can provide the required solution

Cheers...
Suhas
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now