There are some risks here: (I can easily come up some data to make this fail.)
use strict;
use Data::Dumper;
my @AoA = (['a,','b','c'],
['a',',b','c'],
);
my $uAoA = uniqAoA(\@AoA);
print Dumper $uAoA;
sub uniqAoA
{
my ($array) = @_;
my %res;
foreach my $ar (@{$array})
{
my $str = join (",",@{$ar});
$res{$str} = 1;
}
my @kys = keys(%res);
my @final;
foreach(@kys)
{
my @a = split(",",$_);
push @final, [ @a ];
}
return \@final;
}
This should return the orginal AoA, but it returns:
$VAR1 = [
[
'a',
'',
'b',
'c'
]
];
Problems are:
- It thought the two level 2 arrays are the same, when they are different.
- The element contained in the returned array was not originally there.