my %seen_values; for my $aref (@array_of_arrayrefs) { $aref = [ map { $seen_values{$_}++ ? () : $_ } @$aref ]; }