in reply to Combining Duplicate entries in an Array
This may be easier done with a hash, and that way it also doesn't matter if the "duplicates" come right after each other. Pseudo-code:
create a hash foreach key and value pair in 2d array drop .\d from key if key exists in hash increase the key's value by the current value from array else add current key/value to hash loop through hash, printing keys and values
Aaron B.
My Woefully Neglected Blog, where I occasionally mention Perl.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Combining Duplicate entries in an Array
by mmartin (Monk) on Feb 22, 2012 at 20:36 UTC |