in reply to comparing and removing values from an array of hashes
I'd suggest adding another column to your data, and taking two passes through the data:
On the first pass, you can add the new column. Add 0 if there's no value in check, 1 otherwise. Also in this pass, keep track of the maximum quantity and maximum price.
On the second pass, you can use your maxima that you found in pass 1 and selectively turn the new column to 0 if you want to discard the row.
Finally, take a pass through the data and copy the rows that still have a 1 in the new column to your results array.
Strictly, you don't need to add another column for your task, as you could easily perform the missing value test on pass 2. I thought I'd suggest adding it in case you come up with new criteria that may require yet another pass over the data. It's just a simple sifting technique where you keep marking rows to discard. Once you're done, whatever has a 1 in the new column passed all your tests.
...roboticus
When your only tool is a hammer, all problems look like your thumb.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: comparing and removing values from an array of hashes
by perl_walker (Novice) on Oct 22, 2012 at 14:26 UTC | |
by rizzler (Novice) on Oct 22, 2012 at 17:10 UTC |