in reply to Remove redundency from an array
This below code also one of the method to avoid duplicate values from array. It's lengthy code, However, it's one of the alternate method.
my @array = (1,1,3,2,3,5,3,3,7,5,2); my (%ar_hash, @ar); for(@array) { next if($ar_hash{$_}++); push(@ar, $_); } print "@ar"; o/p : 1 3 2 5 7
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Remove redundency from an array
by jdporter (Paladin) on Sep 24, 2007 at 19:01 UTC |
In Section
Seekers of Perl Wisdom