in reply to Removing duplicates in multi-dimensional arrays
Please forgive me, I am a novice at best.
No worries.
it doesn't seem to work on my data.
The problem here is that you haven't shown what your data is and you haven't shown in what way it "doesn't seem to work". This gives the people who want to help you very little to go on. An SSCCE would be ideal.
That said, if you are using an AoA as @rows then you will have trouble. Maybe all you need is:
@rows = do { my %seen; grep { !$seen{$_->[2]}++ } @rows };
But without any data to test on, who can say?
As for explaining the code, you are grepping an array for entries which don't match entries in a hash which you build up as you go along. This is the standard, simplest de-duplication technique (without resorting to modules) as outlined in the FAQ How can I remove duplicate elements from a list or array?.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Removing duplicates in multi-dimensional arrays
by DamnitAddie (Novice) on Oct 03, 2018 at 14:04 UTC | |
by AnomalousMonk (Archbishop) on Oct 03, 2018 at 16:47 UTC |