Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Hi, I'm not on my own computer so I don't have actual code to hand, but I've got a situation where I need to iterate through an array and do something if a number exists in another array. I had loaded the second array into a hash to test with exists while iterating through the first array, but now I realise that the number is not necessarily unique.
How can I set up the second array so that I do not end up doing a for loop within a for loop?
One thing I've been thinking of is storing any repeated numbers in a hash of arrays with the number as key, then if the number exists extract the info and iterate over the hash to extract the information. Is this a right approach?
I'm sorry if this is not clear, I'll be back on my computer later and can provide some code if necessary. Thanks.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: finding exists on non unique information
by graff (Chancellor) on Nov 18, 2007 at 08:20 UTC | |
|
Re: finding exists on non unique information
by bart (Canon) on Nov 18, 2007 at 09:45 UTC |