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";
In reply to Re: How do I remove the duplicates from the array?
by hdb
in thread How do I remove the duplicates from the array?
by PetreAdi
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |