As others already suggested, you need to (1) use a hash for uniqueness and (2) serialize your arrays to make sure they don't match by chance. Here is one of many possible implementations:
#!/usr/bin/env perl # https://www.perlmonks.org/?node_id=1221504 use strict; use warnings; use Data::Dumper; my @aoa = ( [qw[sun and fun]], [qw[sunand fun]], [qw[sun and fun]], [qw[fun and sun]], ); # first off, serialize the array somehow # Multiple methods may exist, depending on expected content of arrays sub concat { my $array = shift; # we replace \ with \\ and use a literal \n for delimiter, # so no confusion may occur return join "\\n", map { s/\\/\\\\/g; $_ } @$array; }; # Use a hash for uniqueness # this would've been grep { !$uniq{$_}++ } @aoa if @aoa was just strin +gs my %uniq; my @no_dupes = grep { !$uniq{ concat($_) }++ } @aoa; # Check the data print Dumper(\@no_dupes); print Dumper(\%uniq);
In reply to Re: Remove Array Duplicates from Array of Arrays
by Dallaylaen
in thread Remove Array Duplicates from Array of Arrays
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |