in reply to How do I find if an array has duplicate elements, if so discard it?
Of course, in this instance you don't want the last line - instead you'd probably want something like:my @a=(1 .. 2); my @b=(2 .. 3); my %c; @c{@a,@b}=(@a,@b); warn "Duplicates exist!" if scalar @c{@a,@b} != (@a+@b);
...which will be out-of-order, but guaranteed duplicate free.my @d=keys %c;
|
|---|