Here is efficient way to remove dup elements in array, Every element is stored in a hash with key as the array element and value as 1. Since a hash cannot have duplicate keys, after populating the hash, the keys from the hash will consist of distinct array elements.my @dup_array = qw\sridhar sridhar guru chan guru hubli hubli hubli hu +rryo\; my %unique_hash; foreach my $x (@dup_array) { $unique_hash{$x} = 1; } @dup_array = keys %unique_hash; print "\n\n\n@dup_array";
In reply to Re^2: Removing Duplicate Array Elements!!!
by SridharKesari
in thread Removing Duplicate Array Elements!!!
by dnickel
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |