5% assure discount from here only

Monday, January 24, 2011

(1) How to remove duplicate element from an array?

Solution :

There are so many solution of that particular problem, but out of
them i had provided the 2 shortest solution overhere.
(1)
use List::MoreUtils qw(uniq);
my @A = (1,2, 2,4, 3, 4, 5) ;
my @B = uniq @A;
print @B;

(2)

my @A = (1,2, 2,4, 3, 4, 5) ;
my %hash = "";

foreach(@A){
$hash{$_} = $_;
}

my @b = keys %hash;
print @b;

No comments:

Post a Comment