Uniq with List::MoreUtils


There are several ways to implement this without using an external module, but why would we want to reinvent the wheel when there is already a good solution in the List::MoreUtils module?

The only problem, but we see it all over the programming world is that this function called "uniq" would return a list of distinct elements instead of the ones that were unique in the original list.


examples/functional/uniq.pl
#!/usr/bin/env perl
use strict;
use warnings;
use List::MoreUtils qw(uniq);

my @data = qw(Earth Mars Earth Venus Earth Mars);
my @unique = uniq @data;

print "@unique\n"; # Earth Mars Venus