in reply to How do I remove the duplicates from the array?
Here is an answer as cryptic (and somewhat wasteful) as your requirements (ignoring LanX extras):
use warnings; use strict; my @array = qw(-20 20 1 1 2 2 2 9 3 -4 -4 5 -20 20 7 7 7); my @array1 = qw( 10 11 7 9 3 3 3 1 3 4 5 5 1 30 8 7 8); for( map{ my $k=$_; [ sort{ $array1[$b]<=>$array1[$a] } grep{ $k eq $a +rray[$_] } 0..$#array ] } @array ) { shift @$_ if @$_==1 or $array1[$$_[0]] ne $array1[$$_[1]]; $array[$_] = $array1[$_] = '' for @$_; } $"=','; print "\@output = (@array);\n\@output1 = (@array1);\n";
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: How do I remove the duplicates from the array?
by LanX (Saint) on Sep 26, 2013 at 14:04 UTC | |
by hdb (Monsignor) on Sep 26, 2013 at 14:18 UTC | |
by LanX (Saint) on Sep 26, 2013 at 14:45 UTC | |
by hdb (Monsignor) on Sep 26, 2013 at 14:48 UTC | |
by LanX (Saint) on Sep 26, 2013 at 14:53 UTC |
In Section
Seekers of Perl Wisdom