473,498 Members | 1,704 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Hash of arrays

3 New Member
I want to compare 2 hashes of arrays in the following manner:

Example:
%hoa=(A1=>[UP1,UP3,UP6],
A2=>[UP1,UP6],
A3=>[UP2,UP10],
);
%hoadip=(UP1=>[UP2,UP3,UP7],
UP2=>[UP10,UP9,UP3],
UP5=>[UP1,UP11],
);
Question:
1. Compare the values of %hoa with the keys of %hoadip
2. Then for each key matched, compare the values of the 2 hashes of arrays
3. Print the matching values
Mar 1 '12 #1
3 1684
numberwhun
3,509 Recognized Expert Moderator Specialist
I think this thread, from here on Bytes.com, will provide the answer that you are looking for.

Regards,

Jeff
Mar 1 '12 #2
sally123
3 New Member
Hello,
The thread you recommended does not directly answer my question. I hope you will be able to help me.

The programming language I am using is perl.

I have the following:
%a=(A1=>[UP1,UP3,UP6],
A2=>[UP1,UP6],
A3=>[UP2,UP10],
);

%b=(UP1=>[UP2,UP3,UP7],
UP2=>[UP10,UP9,UP3],
UP5=>[UP1,UP11],
);

Please keep in mind that the keys are different, so I can't compare them.

Desired output:
A1 has values UP1, UP3, UP6.
Among these, only UP1 is a key in %b.
The values of UP1 are UP2, UP3, UP7. I have to compare these 3 values with the values in %a. Whichever key in %a has any of these values, I have to print them.

Example: A1 has UP1, UP3, UP6. UP1 key has values UP2, UP3, UP7. Among these, UP2 has the key A3 and UP3 has the key A1.
So output is: A1-A3,A1.

I hope this explanation is clear. Please let me know if there are any doubts.
Mar 2 '12 #3
chorny
80 Recognized Expert New Member
At least for me it is not clear. Write an algorithm, not an example. IMHO, you should use foreach or each.
Mar 2 '12 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

4
3671
by: Christian Hackl | last post by:
I honestly wasn't able to find an answer for this design question using Google and Google Groups, so I apologize if it is asked too frequently :) Anyway: Let's say I have a multidimensional array...
34
4129
by: Christopher Benson-Manica | last post by:
If an array is sparse, say something like var foo=; foo=4; foo='baz'; foo='moo'; is there a way to iterate through the entire array? --
47
5024
by: VK | last post by:
Or why I just did myArray = "Computers" but myArray.length is showing 0. What a hey? There is a new trend to treat arrays and hashes as they were some variations of the same thing. But they...
22
4569
by: VK | last post by:
A while ago I proposed to update info in the group FAQ section, but I dropped the discussion using the approach "No matter what color the cat is as long as it still hounts the mice". Over the last...
7
6834
by: Joseph Lee | last post by:
Hi All, I am having problem when i am using hashtable to keep an array of bytes value as keys. Take a look at the code snippet below --------------------------------------------------- ...
1
10066
by: sympatico | last post by:
Hi, I am trying to compare 2 images to check if they are exactly identical (in terms of data), I thought this would be quicker than analysing pixels of the images. I have found lots of examples...
38
10117
by: ssg31415926 | last post by:
I need to compare two string arrays defined as string such that the two arrays are equal if the contents of the two are the same, where order doesn't matter and every element must be unique. ...
19
3807
by: Ole Nielsby | last post by:
How does the GetHashCode() of an array object behave? Does it combine the GetHashCode() of its elements, or does it create a sync block for the object? I want to use readonly arrays as...
5
2172
by: M. Fisher | last post by:
Pardon my ignorance here... I have created arrays such as: var SDET_Lab130= new Array(); SDET_Lab130 = new Array(); SDET_Lab130 = ; SDET_Lab130 = ; SDET_Lab130 = ; SDET_Lab130 = ;...
3
2324
by: keithl | last post by:
Hi (again !) I posted a question yesterday just for info on hashrefs which I have read and it makes sense. Putting this into proactive though has now toally confused me ! I have an XML file...
0
7125
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7165
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7205
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6887
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5462
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3093
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3085
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1419
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
291
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.