Beefy Boxes and Bandwidth Generously Provided by pair Networks Cowboy Neal with Hat
No such thing as a small change
 
PerlMonks  

Re^2: Comparing Hash key with array

by packetstormer (Monk)
on Feb 02, 2012 at 17:21 UTC ( #951498=note: print w/ replies, xml ) Need Help??


in reply to Re: Comparing Hash key with array
in thread Comparing Hash key with array

Here is the data in very simple form

$VAR1 = { '_LFOGH4MI5' => [ '_LFOGH4MI5', '201200260', 'Software Extraction Util', 'Jane Smith', 'Closed', 'Database Query', 'email1@email.com', 'email2@email.com' ], '_W9E2B5DBZ' => [ '_W9E2B5DBZ', '201200261', 'TEST: Another test to test the testy thin +g', 'Mike Jones', 'Closed', 'HIP', 'email1@email.com', 'email2@email.com' ] }; $VAR1 = [ [ '_LFOGH4MI5', '<P>Where is the extraction utily for the console database +?.</P>', '<P>I uploaded it to our website for you to download.</P>' ], [ '_W9E2B5DBZ', '<P>Problem2</P>', '<P>Res2</P>' ], [ '_W9E2B5DBZ', '<P>Problem 1- teest</P>', '<P>Res1 - teest</P>' ], [ '_W9E2B5DBZ', '<P>Prob3</P>', '<P>res3</P>' ] ];

So, I have a hash with the unique ID as it's key. In another part of the database is another table with problems/resolutions attached to the same unique ID. That is contained in the array (in array references). Each array has the unique ID in it first element.

What I would like to do is start on that hash and take it's key. The run through the array and anywhere I get a match for the same ID push the rest of the array into the original value of the hash. In some cases, like above, there might be many arrays with the same ID (loads of problems/resolutions attached to the same case).

I'd really appreciate any help, my head is set to burst!
BTW, I have tried to lump the data together at the SQL end but datatype differences are stopping me grouping them there.

EDIT: Hash should end up like:

'_LFOGH4MI5' => [ '_LFOGH4MI5', '201200260', 'Software Extraction Util', 'Jane Smith', 'Closed', 'Database Query', 'email1@email.com', 'email2@email.com' '<P>Where is the extraction utily for the c +onsole database?.</P>', '<P>I uploaded it to our website for you to download.</P>' ], '_W9E2B5DBZ' => [ '_W9E2B5DBZ', '201200261', 'TEST: Another test to test the testy thin +g', 'Mike Jones', 'Closed', 'HIP', 'email1@email.com', 'email2@email.com' '<P>Problem2</P>', '<P>Res2</P>' '<P>Problem 1- teest</P>', '<P>Res1 - teest</P>' '<P>Prob3</P>', '<P>res3</P>' ] };


Comment on Re^2: Comparing Hash key with array
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (4)
As of 2014-04-21 10:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (492 votes), past polls