Perl uniq array, to remove duplications
With Bash, you can simply remove duplications by typing:
sort file | uniq
With Perl, it’s more funny. I found those pieces of code in Code Snippets.
Simple ‘Uniq’ code
my @uniq = keys %{{ map { $_ => 1 } @list }};
Another one, more efficient
my %u = ();
@uniqed = grep {defined} map {
if (exists $u{$_}) { undef; } else { $u{$_}=undef;$_; }
} @list;
undef %u;

September 21st, 2006 at 6:20 pm
ou les deux, exec “sort $file | uniq”;
September 21st, 2006 at 6:22 pm
exec is for lamers
September 21st, 2006 at 8:00 pm
run u prog as faster as u can!
et puis pkoi reinventer la roue swobo. :p
September 22nd, 2006 at 5:24 am
Hmm, I played with Perl in a previous life, so I hope I am not embarassing myself by commenting here

First, it seems that you’re making the assumption that you can change the sorting order of the input array thus the use of the map. But sometimes you need to preserve the original order and the proposed soultions won’t work. Second, the map is ok up to small to medium sized array, but it won’t scale for big arrays and in this case there is nothing better than a n old classic loop, sometimes simple is better
Nice blog you have here, I saw your profile and I am very impressed and also proud of your achievements, i am myself a geek but an old one (I am 40). Keep it up, thks.
September 22nd, 2006 at 4:46 pm
Welcome Samsoum
Cool to find and old generation hacker: We can learn from your experience!
In fact, this algorithm doesn’t keep the array elements order; it sorts them instead.
Have fun!