Here’s one approach: convert each inner array into a single string, and store it in a hash for future lookup:
use strict; use warnings; use Data::Dump; my @MyArrayOfArray = ( [ "hello", "day", "sun and fun" ], [ 2, "okay", "may" ], [ "hello", "day", "sun and fun" ], [ 2, "okay", "may" ], [ "hello", "sun and fun", "day" ], [ 2, "okay", "may" ], ); my (%hash, @AoA2); for (@MyArrayOfArray) { my $key = join '', @$_; push @AoA2, $_ unless exists $hash{ $key }; ++$hash{ $key }; } dd \@AoA2;
Output:
18:32 >perl 1924_SoPW.pl [ ["hello", "day", "sun and fun"], [2, "okay", "may"], ["hello", "sun and fun", "day"], ] 18:32 >
Hope that helps,
| Athanasius <°(((>< contra mundum | Iustus alius egestas vitae, eros Piratica, |
In reply to Re: Remove Array Duplicates from Array of Arrays
by Athanasius
in thread Remove Array Duplicates from Array of Arrays
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |