in reply to A more complete Unique()
in thread Optimize - Checking multiple occurences of elements in an array
This retains order and does not break references. It does have the problem with empty strings vs undefs cancelling each other away when they (probably) shouldn't, but that's easily fixed:my %seen; my @unique = grep !$seen{$_}++, @array;
my (%seen, $seen_undef); my @unique = grep defined ? !$seen{$_}++ : !$seen_undef++, @array;
Makeshifts last the longest.
|
---|