#!/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 strings my %uniq; my @no_dupes = grep { !$uniq{ concat($_) }++ } @aoa; # Check the data print Dumper(\@no_dupes); print Dumper(\%uniq);