monkfan has asked for the wisdom of the Perl Monks concerning the following question: ⭐ (arrays)
Given this:
I wish to return simply this:my @AoA = ( ['a','b','c'], ['a','b','c'], ['a','b','d'], ['a','b','d'], );
From the original posting in SoPW, one can find many answers. One of them is (by TedPride), seems to me to be the most compact of them all:my @uAoA = ( ['a','b','c'], ['a','b','d'], );
use strict; use warnings; use Data::Dumper; my @AoA = ( ['a','b','c'], ['a','b','c'], ['a','b','d'], ['a','b','d'], ); my (%h, @uAoA); for (@AoA) { push @uAoA, $_ if !$h{join $;, @$_}++; } print Dumper \@uAoA;
Originally posted as a Categorized Question.
Back to
Seekers of Perl Wisdom